Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.4.0, 2.4.1
-
None
Description
Given the 2 following classes:
class A<T extends Number> { final T value A(T value) { this.value = value } }
and
class B extends A<Integer> { B(Integer value) { super(value) } }
the generated stub for B does not compile, as the constructor parameter is cast to the bounded type instead of the actual type:
public class B extends A<java.lang.Integer> { ; public B (java.lang.Integer value) { super ((java.lang.Number)null); } // ... }
The error returned by the compiler is:
target/generated-sources/groovy-stubs/main/B.java:[13,1] constructor A in class A<T> cannot be applied to given types; required: java.lang.Integer found: java.lang.Number reason: actual argument java.lang.Number cannot be converted to java.lang.Integer by method invocation conversion
I've attached a test case, which is also available on Github.