Skip to content

Commit 73c1d80

Browse files
fine tuning from self review:
- propagate failures during resolution of capture bounds
1 parent fbaf0aa commit 73c1d80

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

  • org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup

org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/BoundSet.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,10 @@ protected TypeBinding getP(int i) {
702702
System.arraycopy(otherBounds, 0, allBounds, 1, n-1);
703703
bi = context.environment.createIntersectionType18(allBounds);
704704
}
705-
if (addTypeBoundsFromWildcardBound(context, theta, wildcardBinding.boundKind, t, r, bi))
705+
ReductionResult result = addTypeBoundsFromWildcardBound(context, theta, wildcardBinding.boundKind, t, r, bi);
706+
if (result == ReductionResult.FALSE)
707+
return false;
708+
else if (result == ReductionResult.TRUE)
706709
capturesToRemove.add(gAlpha);
707710
}
708711
}
@@ -715,7 +718,8 @@ protected TypeBinding getP(int i) {
715718
TypeBound bound = it.next();
716719
if (!(bound.right instanceof InferenceVariable)) {
717720
if (wildcardBinding.boundKind == Wildcard.SUPER) {
718-
reduceOneConstraint(context, ConstraintTypeFormula.create(bound.right, t, ReductionResult.SUBTYPE));
721+
if (!reduceOneConstraint(context, ConstraintTypeFormula.create(bound.right, t, ReductionResult.SUBTYPE)))
722+
return false;
719723
capturesToRemove.add(gAlpha);
720724
} else {
721725
return false;
@@ -745,8 +749,8 @@ protected TypeBinding getP(int i) {
745749
}
746750

747751
// try to infer and reduce a new constraint based on details of a given capture bound
748-
// return true iff a new constraint has been added indeed
749-
boolean addTypeBoundsFromWildcardBound(InferenceContext18 context, InferenceSubstitution theta, int boundKind, TypeBinding t,
752+
// return TRUE or FALSE iff a new constraint has been added indeed
753+
ReductionResult addTypeBoundsFromWildcardBound(InferenceContext18 context, InferenceSubstitution theta, int boundKind, TypeBinding t,
750754
TypeBinding r, TypeBinding bi) throws InferenceFailureException {
751755
ConstraintFormula formula = null;
752756
if (boundKind == Wildcard.EXTENDS) {
@@ -758,10 +762,11 @@ boolean addTypeBoundsFromWildcardBound(InferenceContext18 context, InferenceSubs
758762
formula = ConstraintTypeFormula.create(theta.substitute(theta, bi), r, ReductionResult.SUBTYPE, true);
759763
}
760764
if (formula != null) {
761-
reduceOneConstraint(context, formula);
762-
return true;
765+
if (!reduceOneConstraint(context, formula))
766+
return ReductionResult.FALSE;
767+
return ReductionResult.TRUE;
763768
}
764-
return false;
769+
return null;
765770
}
766771

767772
private ConstraintTypeFormula combineSameSame(TypeBound boundS, TypeBound boundT, Map<InferenceVariable,TypeBound> properTypesByInferenceVariable) {

0 commit comments

Comments
 (0)