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 2022/04/30 20:08:00 UTC
[jira] [Created] (GROOVY-10614) Fail to infer the correct type argument when having conditionals and diamond operator
Thodoris Sotiropoulos created GROOVY-10614:
----------------------------------------------
Summary: Fail to infer the correct type argument when having conditionals and diamond operator
Key: GROOVY-10614
URL: https://issues.apache.org/jira/browse/GROOVY-10614
Project: Groovy
Issue Type: Bug
Components: Static Type Checker
Reporter: Thodoris Sotiropoulos
I think this is a regression bug, because Groovy 4.0.2 compiles the program successfully.
{code}
class Foo<T> {}
class Test {
public static void test() {
foo((true) ? new Foo<Boolean>() : new Foo<>());
}
public static void foo(Foo<Boolean> x) {}
}
{code}
h3. Actual behaviour
{code}
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
test.groovy: 5: [Static type checking] - Cannot call Test#foo(Foo<java.lang.Boolean>) with arguments [Foo<? extends java.lang.Object>]
@ line 5, column 5.
foo((true) ? new Foo<Boolean>() : new Foo<>());
^
1 error
{code}
h3. Expected Behaviour
Compile successfully
Tested against master (commit: e183dc8e04a8ca8762e85e21ac3ee0c03138b6e1)
--
This message was sent by Atlassian Jira
(v8.20.7#820007)