new inference: choose proper type from equality bounds if present

This commit is contained in:
anna
2013-10-30 14:22:29 +01:00
parent f6a8f67f8c
commit 3c0c498353
2 changed files with 6 additions and 5 deletions
@@ -419,8 +419,8 @@ public class InferenceSession {
PsiType bound = null;
for (PsiType eqBound : eqBounds) {
if (eqBound == null) continue;
if (bound != null && !isProperType(eqBound)) continue;
bound = acceptBoundsWithRecursiveDependencies(typeParameter, eqBound, substitutor);
if (bound != null) break;
}
if (bound != null) {
if (bound instanceof PsiCapturedWildcardType && eqBounds.size() > 1) {
@@ -148,13 +148,14 @@ public class SubtypingConstraint implements ConstraintFormula {
if (myS instanceof PsiWildcardType) {
return inferenceVariable != null && inferenceVariable.isCaptured();
} else {
if (inferenceVariable != null) {
inferenceVariable.addBound(myS, InferenceBound.EQ);
final InferenceVariable inferenceVariableS = session.getInferenceVariable(myS);
if (inferenceVariableS != null) {
inferenceVariableS.addBound(myT, InferenceBound.EQ);
return true;
}
inferenceVariable = session.getInferenceVariable(myS);
if (inferenceVariable != null) {
inferenceVariable.addBound(myT, InferenceBound.EQ);
inferenceVariable.addBound(myS, InferenceBound.EQ);
return true;
}
constraints.add(new SubtypingConstraint(myT, myS, true));