You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Thodoris Sotiropoulos (Jira)" <ji...@apache.org> on 2023/04/07 13:05:00 UTC
[jira] [Created] (GROOVY-11002) Unexpected type mismatch when having overloaded methods with variable arguments
Thodoris Sotiropoulos created GROOVY-11002:
----------------------------------------------
Summary: Unexpected type mismatch when having overloaded methods with variable arguments
Key: GROOVY-11002
URL: https://issues.apache.org/jira/browse/GROOVY-11002
Project: Groovy
Issue Type: Bug
Components: Static Type Checker
Reporter: Thodoris Sotiropoulos
I have the following program
{code}
import java.util.function.Supplier;
class Main {
static final void test() {
Main.<String>m(() -> "df", "fdaf");
}
static <T> void m(Supplier<T> x, T... y) {}
static <T extends Comparable<? extends T>> void m(T...y) {}
}
{code}
h3. Actual behavior
{code}
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
test.groovy: 5: [Static type checking] - Cannot return value of type java.lang.String for lambda expecting int
@ line 5, column 26.
Main.<String>m(() -> "df", "fdaf");
^
1 error
{code}
h3. Expected behavior
Compile successfully
h3. Notes
Tested against master (commit: a4e0d6de9cc2d8ecb48b48df501e63ec1735d837)
Test case adapted from:
{code}
class Main {
static final void test() {
org.apache.commons.lang3.ObjectUtils.<String>median((stills, impeaches) -> 86 , "fdaf");
}
}
{code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)