new inference: correct capture incorporation (IDEA-149807)

This commit is contained in:
Anna Kozlova
2015-12-28 19:07:22 +01:00
parent b6894df57d
commit 2be1c64a13
5 changed files with 22 additions and 2 deletions
@@ -167,7 +167,7 @@ public class InferenceIncorporationPhase {
for (PsiType lowerBound : lowerBounds) {
if (mySession.getInferenceVariable(lowerBound) == null) {
addConstraint(new StrictSubtypingConstraint(lowerBound, superBound));
addConstraint(new StrictSubtypingConstraint(superBound, lowerBound));
}
}
}
@@ -674,7 +674,7 @@ public class InferenceSession {
}
substitutedCapture = elementFactory.createType(psiClass, newParameters);
myIncorporationPhase.addCapture(copy, substitutedCapture);
myIncorporationPhase.addCapture(copy, (PsiClassType)returnType);
addConstraint(new TypeCompatibilityConstraint(targetType, substitutedCapture));
}
} else {
@@ -32,6 +32,7 @@ public class StrictSubtypingConstraint implements ConstraintFormula {
private PsiType myS;
private PsiType myT;
//t < s
public StrictSubtypingConstraint(PsiType t, PsiType s) {
myT = t;
myS = s;
@@ -0,0 +1,15 @@
import java.util.List;
class Main {
static List<? extends Child> foo() {
return get ();
}
static <T extends Base> List<? extends T> get() {
return null;
}
static class Base {}
static class Child extends Base {}
}
@@ -347,6 +347,10 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase
doTest();
}
public void testCaptureConstraint() throws Exception {
doTest();
}
private void doTest() throws Exception {
doTest(false);
}