-
Notifications
You must be signed in to change notification settings - Fork 164
Description
With this:
public class Test {
public static void main(String[] args) {
Z<B> z = new Z<>(List.of(
new Y<>(new A()),
new Y<>(new B()),
new Y<>(new C())));
}
public static record Z<T>(List<? extends X<? super T>> l) {}
public static record Y<T>(T t) implements X<T> {}
public static interface X<T> {}
public static class A {}
public static class B extends A {}
public static class C extends B {}
}ECJ fails to compile with Cannot infer type arguments for Z<> whilst Javac succeeds
While debugging this I noticed I noticed that <Z#0-T'#5 extends Z#1-T'#0> <: <Z#2-T'#1> (the upper bounds of Z#0-T'#5 are Z#1-T'#0, Z#2-T'#1, Z#3-T'#2) is reduced to false since isSubtypeOf isn't overriden by CaptureBinding18 so only the first bound is checked and that test2.Test.Y<Z#1-T'#0> <: test2.Test.X<? super Z#1-T'#0&Z#2-T'#1&Z#3-T'#2> is also reduced to false since currently TypeBinding.isTypeArgumentContainedBy only checks the lower bound.
With those 2 issues fixed ECJ then resolves E#4 to Test.Y<? extends java.lang.Object> since there is no ? super wildcard in the lower bounds for JLS §4.10.4 to output a ? super wildcard and without the z captures ECJ resolves E#4 to have a lower bound of Test.Y<? extends Test.A> for the same reason.