inference: don't check bounds for variables which may depend on another variable with inconsistency bounds

This commit is contained in:
Anna Kozlova
2016-03-03 13:31:40 +01:00
parent d8c289c77e
commit 6c5fc69ae9
3 changed files with 6 additions and 9 deletions
@@ -602,6 +602,7 @@ public class InferenceSession {
}
PsiSubstitutor prepareSubstitution() {
boolean foundErrorMessage = false;
Iterator<List<InferenceVariable>> iterator = InferenceVariablesOrder.resolveOrderIterator(myInferenceVariables, this);
while (iterator.hasNext()) {
final List<InferenceVariable> variables = iterator.next();
@@ -610,7 +611,9 @@ public class InferenceSession {
PsiType instantiation = inferenceVariable.getInstantiation();
//failed inference
if (instantiation == PsiType.NULL) {
checkBoundsConsistency(mySiteSubstitutor, inferenceVariable);
if (!foundErrorMessage) {
foundErrorMessage = checkBoundsConsistency(mySiteSubstitutor, inferenceVariable) == PsiType.NULL;
}
mySiteSubstitutor = mySiteSubstitutor
.put(typeParameter, JavaPsiFacade.getInstance(typeParameter.getProject()).getElementFactory().createType(typeParameter));
}
@@ -12,10 +12,7 @@ class Test {
SuperFoo<String> ls = foo(<error descr="no instance(s) of type variable(s) exist so that String conforms to Number
inference variable R has incompatible bounds:
equality constraints: String
upper bounds: Object, Number
inference variable X has incompatible bounds:
equality constraints: R
upper bounds: Number">() -> new Foo<>()</error>);
upper bounds: Object, Number">() -> new Foo<>()</error>);
SuperFoo<Integer> li = foo(() -> new Foo<>());
SuperFoo<?> lw = foo(() -> new Foo<>());
}
@@ -29,10 +29,7 @@ abstract class NoFormalParamTypeInferenceNeeded {
Integer zip = zip(a -> zip(<error descr="no instance(s) of type variable(s) exist so that Object conforms to Integer
inference variable R has incompatible bounds:
lower bounds: Object
upper bounds: Object, Integer
inference variable R has incompatible bounds:
lower bounds: Object
upper bounds: Object, R, Integer">text -> text</error>));
upper bounds: Object, Integer">text -> text</error>));
}
}