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 2021/11/15 09:29:00 UTC
[jira] [Created] (GROOVY-10368) STC fails to instantiate type variable when using diamond operator
Thodoris Sotiropoulos created GROOVY-10368:
----------------------------------------------
Summary: STC fails to instantiate type variable when using diamond operator
Key: GROOVY-10368
URL: https://issues.apache.org/jira/browse/GROOVY-10368
Project: Groovy
Issue Type: Bug
Components: Static Type Checker
Reporter: Thodoris Sotiropoulos
I have the following program
{code:java}
class A<T extends Number> {
A(String x) {}
}
class B {
void m(A<Integer> x) {}
}
class Test {
void test() {
B x = new B();
x.m(new A<>(""));
}
}
{code}
h3. Actual behaviour
{code}
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
test.groovy: 14: [Static type checking] - Cannot call B#m(A<java.lang.Integer>) with arguments [A<# extends java.lang.Number>]
@ line 14, column 5.
x.m(new A<>(""));
^
1 error
{code}
h3. Expected behaviour
Compile successfully
Tested against master (https://github.com/apache/groovy/commit/cf2f77fb033a10d36c4db3a7ff07a2b04631afcf)
--
This message was sent by Atlassian Jira
(v8.20.1#820001)