mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
new inference: strict subtyping: skip raw types
This commit is contained in:
+4
@@ -19,6 +19,7 @@ import com.intellij.psi.*;
|
||||
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.TypeConversionUtil;
|
||||
|
||||
import java.util.List;
|
||||
@@ -94,6 +95,9 @@ public class StrictSubtypingConstraint implements ConstraintFormula {
|
||||
if (!(myS instanceof PsiClassType)) return false;
|
||||
PsiClassType.ClassResolveResult SResult = ((PsiClassType)myS).resolveGenerics();
|
||||
PsiClass SClass = SResult.getElement();
|
||||
if (((PsiClassType)myT).isRaw()) {
|
||||
return SClass != null && InheritanceUtil.isInheritorOrSelf(SClass, CClass, true);
|
||||
}
|
||||
final PsiSubstitutor tSubstitutor = TResult.getSubstitutor();
|
||||
final PsiSubstitutor sSubstitutor = SClass != null ? TypeConversionUtil.getClassSubstitutor(CClass, SClass, SResult.getSubstitutor()) : null;
|
||||
if (sSubstitutor != null) {
|
||||
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
class Test {
|
||||
interface I<K> {}
|
||||
|
||||
{
|
||||
I i = foo(TreeMap::new);
|
||||
}
|
||||
|
||||
<M extends Map<Integer, Integer>> I<M> foo(Supplier<M> mapFactory) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+4
@@ -169,6 +169,10 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testRawTargetType() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user