mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
new inference: correct capture incorporation (IDEA-149807)
This commit is contained in:
+1
-1
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -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 {
|
||||
|
||||
+1
@@ -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;
|
||||
|
||||
+15
@@ -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 {}
|
||||
}
|
||||
+4
@@ -347,6 +347,10 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testCaptureConstraint() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() throws Exception {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user