[ https://issues.apache.org/jira/browse/GROOVY-10367?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Eric Milles updated GROOVY-10367: --------------------------------- Fix Version/s: 3.0.11 > 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 > Assignee: Eric Milles > Priority: Major > Fix For: 5.0.0-alpha-1, 3.0.11, 4.0.2 > > > 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)