mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 09:19:13 +07:00
new inference: process captured wildcard with array type bound
This commit is contained in:
+9
-3
@@ -20,7 +20,6 @@ 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;
|
||||
@@ -78,9 +77,16 @@ public class StrictSubtypingConstraint implements ConstraintFormula {
|
||||
return true;
|
||||
}
|
||||
if (myT instanceof PsiArrayType) {
|
||||
if (!(myS instanceof PsiArrayType)) return false; //todo most specific array supertype
|
||||
PsiType sType = myS;
|
||||
if (myS instanceof PsiCapturedWildcardType) {
|
||||
final PsiType upperBound = ((PsiCapturedWildcardType)myS).getUpperBound();
|
||||
if (upperBound instanceof PsiArrayType) {
|
||||
sType = upperBound;
|
||||
}
|
||||
}
|
||||
if (!(sType instanceof PsiArrayType)) return false; //todo most specific array supertype
|
||||
final PsiType tComponentType = ((PsiArrayType)myT).getComponentType();
|
||||
final PsiType sComponentType = ((PsiArrayType)myS).getComponentType();
|
||||
final PsiType sComponentType = ((PsiArrayType)sType).getComponentType();
|
||||
if (!(tComponentType instanceof PsiPrimitiveType) && !(sComponentType instanceof PsiPrimitiveType)) {
|
||||
constraints.add(new StrictSubtypingConstraint(tComponentType, sComponentType));
|
||||
return true;
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
import java.util.List;
|
||||
|
||||
abstract class Test {
|
||||
|
||||
public static void foo(List<? extends String[]> aClass) {
|
||||
copyOfRange(aClass);
|
||||
}
|
||||
|
||||
public static <P> void copyOfRange(List<? extends P[]> newType) {}
|
||||
}
|
||||
+4
@@ -339,6 +339,10 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testCapturedWildcardWithArrayTypeBound() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() throws Exception {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user