-
Notifications
You must be signed in to change notification settings - Fork 162
Description
The following use case worked for all previous releases and compiles fine with javac:
package eclipsebug;
public class EclipseBug {
void error1() {
var someObject = getObject(); // <<--- Compiler complains here
}
void error2() {
SomeObject<? extends SomeType<?, ? extends SpecialLocation>, ? extends SpecialLocation, ?> theObject;
method(theObject); // <<--- Compiler complains here
}
void error3() {
SomeObject<? extends SomeType<?, ? extends SpecialLocation>, ? extends SpecialLocation, ?> theObject;
SomeObject<? extends SomeType<?, ? extends SpecialLocation>, ? extends SpecialLocation, ?> theObject2 = theObject; // <<--- Compiler complains here
}
void method(SomeObject<? extends SomeType<?, ? extends SpecialLocation>, ? extends SpecialLocation, ?> theObject) {
}
private SomeObject<? extends SomeType<?, ? extends SpecialLocation>, ? extends SpecialLocation, ?> getObject() {
return null;
}
static interface SomeLocation {
}
static interface SpecialLocation extends SomeLocation {
}
static interface SomeType<O extends SomeObject<? extends SomeType<?, L>, L, ? extends SomeObject<?, ?, ?>>, L extends SomeLocation> {
}
public interface SomeObject<T extends SomeType<?, L>, L extends SomeLocation, P extends SomeObject<?, ?, ?>> {
}
}This code compiles fine with javac and Eclipse 2025-09.
But it fails with 2025-12 (4.38.0). The compiler complains with the following errors.
In error1 the error message is:
Type mismatch: cannot convert from EclipseBug.SomeObject<capture#1-of ? extends EclipseBug.SomeType<?,? extends EclipseBug.SpecialLocation>,capture#2-of ? extends EclipseBug.SpecialLocation,capture#3-of ?> to EclipseBug.SomeObject<? extends EclipseBug.SomeType<?,? extends EclipseBug.SpecialLocation> & EclipseBug.SomeType<?,? extends EclipseBug.SpecialLocation>,? extends EclipseBug.SpecialLocation,?>As the return type of getObject() is fully specified the compiler should infer that type and assign it to the variable declared as var without any issue.
In error2 the error message is:
The method method(EclipseBug.SomeObject<? extends EclipseBug.SomeType<?,? extends EclipseBug.SpecialLocation>,? extends EclipseBug.SpecialLocation,?>) in the type EclipseBug is not applicable for the arguments (EclipseBug.SomeObject<capture#6-of ? extends EclipseBug.SomeType<?,? extends EclipseBug.SpecialLocation>,capture#7-of ? extends EclipseBug.SpecialLocation,capture#8-of ?>)The parameter of the method has the exact same type as the local variable, so it should be applicable to call the method.
In error3 the error message is:
Type mismatch: cannot convert from EclipseBug.SomeObject<capture#11-of ? extends EclipseBug.SomeType<?,? extends EclipseBug.SpecialLocation>,capture#12-of ? extends EclipseBug.SpecialLocation,capture#13-of ?> to EclipseBug.SomeObject<? extends EclipseBug.SomeType<?,? extends EclipseBug.SpecialLocation>,? extends EclipseBug.SpecialLocation,?>Here the compiler complains about assigning a value of one local variable to the other local variable, even though the two local variables are declared with the exact same type.
This issue will bock us from upgrading Eclipse until it is fixed.
@stephan-herrmann could you please look into this? It might be related to #4635
Best Regards
Michael