Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
Description
This might be related to GROOVY-10662.
I have the following program
class A<T, X> { } class Test<T> { void test(A<Double, ? extends T> x) { A<Double, ? extends T> y = x; A<Double, ? extends T> z = (true) ? y : x; } }
Actual behavior
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: test.groovy: 7: [Static type checking] - Incompatible generic argument types. Cannot assign A<java.lang.Double, java.lang.Object> to: A<java.lang.Double, ? extends T> @ line 7, column 32. A<Double, ? extends T> z = (true) ? y : x; ^ 1 error
Expected behavior
Compile successfully
Notes: The bug is triggered when the following conditions hold:
- The name of the first type parameter of class A matches the type parameter of class Test.
- We the wildcard type "? extends T" for instantiating the type constructor A on lines 5, 6, 7.
Tested against master (commit: 1ea7b9619e7a3ec0da9a3e065f78e394206ea632)