Skip to content

Commit

Permalink
ECJ fails to compile method invocation while javac successfully
Browse files Browse the repository at this point in the history
compiles eclipse-jdt#1591

hapless attempt to mimic javac behavior, causing regressions in
GenericsRegressionTest_1_8.testBug472851()
  • Loading branch information
stephan-herrmann committed Apr 9, 2024
1 parent 8cf2f7a commit 27950e6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,8 @@ private ConstraintTypeFormula combineSameSameWithProperType(TypeBound boundLeft,
InferenceVariable alpha = boundLeft.left;
TypeBinding left = boundRight.left; // no substitution since S inference variable and (S != α) per precondition
TypeBinding right = boundRight.right.substituteInferenceVariable(alpha, u);
if (TypeBinding.equalsEquals(right, boundRight.right))
return null; // no new information
return ConstraintTypeFormula.create(left, right, ReductionResult.SAME, boundLeft.isSoft||boundRight.isSoft);
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ public Object reduce(InferenceContext18 inferenceContext) {
if (this.left.kind() != Binding.WILDCARD_TYPE) {
return ConstraintTypeFormula.create(this.left, this.right, SAME, this.isSoft);
} else {
// FIXME: with the pending change in BoundSet, removing this might actually help:
// TODO: speculative addition:
if (this.right instanceof InferenceVariable)
return new TypeBound((InferenceVariable) this.right, this.left, SAME, this.isSoft);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10682,4 +10682,25 @@ public int getWeaveCount() {
"----------\n",
null, true, customOptions);
}
public void testGH1591() {
runConformTest(
new String[] {
"Outer.java",
"""
import java.io.Serializable;
import java.util.List;
import java.util.function.Supplier;
public class Outer {
public void test() {
Supplier<? extends List<? extends Serializable>> supplier = () -> null;
error(supplier.get(), "");
}
public <T, V extends Serializable> void error(List<V> v2, T t) {}
}
"""
});
}
}

0 comments on commit 27950e6

Please sign in to comment.