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:22:00 UTC
[jira] [Created] (GROOVY-10367) STC fails to infer the correct type for type variable in the presence of the diamond operator and bounded polymorphism
Thodoris Sotiropoulos created GROOVY-10367:
----------------------------------------------
Summary: STC fails to infer the correct type for type variable in the presence of the diamond operator and bounded polymorphism
Key: GROOVY-10367
URL: https://issues.apache.org/jira/browse/GROOVY-10367
Project: Groovy
Issue Type: Bug
Components: Static Type Checker
Reporter: Thodoris Sotiropoulos
This issue may be related to GROOVY-10343.
I have the following program
{code:java}
class A<Z, P extends Z> {
Z f;
A(Z f) {}
}
class B<Z extends Number> {
Z f;
void test() {
f = new A<>((Z) null).f;
}
}
{code}
h3. Actual behaviour
{code}
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
test.groovy: 10: [Static type checking] - Cannot assign value of type java.lang.Object to variable of type Z
@ line 10, column 9.
f = new A<>((Z) null).f;
^
1 error
{code}
h3. Expected behaviour
Compile successfully
NOTE: Replacing `Z extends Number` with `Z` leads to a successful compilation.
Tested against master (https://github.com/apache/groovy/commit/cf2f77fb033a10d36c4db3a7ff07a2b04631afcf)
--
This message was sent by Atlassian Jira
(v8.20.1#820001)