Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Method call compiles with javac but not ecj #3457

Open
coehlrich opened this issue Dec 16, 2024 · 0 comments
Open

Method call compiles with javac but not ecj #3457

coehlrich opened this issue Dec 16, 2024 · 0 comments
Assignees
Labels
javac ecj not compatible with javac

Comments

@coehlrich
Copy link
Contributor

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).

@jukzi jukzi added the javac ecj not compatible with javac label Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
javac ecj not compatible with javac
Projects
None yet
Development

No branches or pull requests

3 participants