mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
new inference: check intersection type of upper bound to detect substitution (IDEA-165011)
This commit is contained in:
+10
@@ -20,6 +20,7 @@ import com.intellij.psi.impl.source.resolve.graphInference.InferenceBound;
|
||||
import com.intellij.psi.impl.source.resolve.graphInference.InferenceSession;
|
||||
import com.intellij.psi.impl.source.resolve.graphInference.InferenceVariable;
|
||||
import com.intellij.psi.util.InheritanceUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.psi.util.TypeConversionUtil;
|
||||
|
||||
import java.util.HashSet;
|
||||
@@ -135,6 +136,15 @@ public class StrictSubtypingConstraint implements ConstraintFormula {
|
||||
if (upperBound instanceof PsiClassType) {
|
||||
sType = (PsiClassType)upperBound;
|
||||
}
|
||||
else if (upperBound instanceof PsiIntersectionType) {
|
||||
for (PsiType type : ((PsiIntersectionType)upperBound).getConjuncts()) {
|
||||
PsiClass sCandidate = PsiUtil.resolveClassInClassTypeOnly(type);
|
||||
if (sCandidate != null && InheritanceUtil.isInheritorOrSelf(sCandidate, CClass, true)) {
|
||||
sType = (PsiClassType)type;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (sType == null) return false;
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
|
||||
import java.util.List;
|
||||
|
||||
class Test {
|
||||
<B> void foo(final Enum<? extends List<B>> f) {}
|
||||
|
||||
void bar(final Enum<? extends List<String>> e) {
|
||||
foo(e);
|
||||
}
|
||||
}
|
||||
+4
@@ -495,6 +495,10 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testRecursiveTypeWithCapture() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() throws Exception {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user