You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public class Test {
public void test() {
this.error(new TypeToken<A2<?>>() {});
}
public <T extends B1> void error(TypeToken<? extends A1<? extends T>> type) {}
public static abstract class TypeToken<T> {}
public static class A1<T extends B1> {}
public static class A2<T extends B2> extends A1<T> {}
public static class B1 {}
public static class B2 extends B1 {}
}
javac compiles successfully while ecj fails with the error The method error(Test.TypeToken<? extends Test.A1<? extends T>>) in the type Test is not applicable for the arguments (new Test.TypeToken<Test.A2<?>>(){})
The issue seems to be that a type bound of T#0 :> java.lang.Object gets added from the constraint that A2<?> is a subtype of A1<? extends T#0> due to the unbounded wildcard from A2<?> being preserved while getting the supertype even though JLS §4.10.2 suggests that the supertypes of the capture conversion of A2<?> should be used instead
Given a generic class or interface C with type parameters F1,...,Fn (n > 0), the direct supertypes of the parameterized type C<R1,...,Rn> where at least one of the Ri (1 ≤ i ≤ n) is a wildcard type argument, are the direct supertypes of the parameterized type C<X1,...,Xn> which is the result of applying capture conversion to C<R1,...,Rn> (§5.1.10).
The text was updated successfully, but these errors were encountered:
javac compiles successfully while ecj fails with the error
The method error(Test.TypeToken<? extends Test.A1<? extends T>>) in the type Test is not applicable for the arguments (new Test.TypeToken<Test.A2<?>>(){})
The issue seems to be that a type bound of
T#0 :> java.lang.Object
gets added from the constraint thatA2<?>
is a subtype ofA1<? extends T#0>
due to the unbounded wildcard fromA2<?>
being preserved while getting the supertype even though JLS §4.10.2 suggests that the supertypes of the capture conversion ofA2<?>
should be used insteadThe text was updated successfully, but these errors were encountered: