subtyping constraint: apply capture conversion for captured wildcard bound according to the direct supertype of parameterized type specification

This commit is contained in:
Anna Kozlova
2016-06-22 15:24:15 +03:00
parent a330f9c2f7
commit 3805d51554
4 changed files with 23 additions and 1 deletions
@@ -94,6 +94,9 @@ public class JavaClassSupersImpl extends JavaClassSupers {
}
}
}
else if (lowerBound instanceof PsiCapturedWildcardType) {
return processLowerBound(((PsiCapturedWildcardType)lowerBound).getUpperBound(), derivedClass, scope, derivedSubstitutor);
}
return null;
}
@@ -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;
@@ -133,7 +134,7 @@ public class StrictSubtypingConstraint implements ConstraintFormula {
else if (myS instanceof PsiCapturedWildcardType) {
final PsiType upperBound = ((PsiCapturedWildcardType)myS).getUpperBound();
if (upperBound instanceof PsiClassType) {
sType = (PsiClassType)upperBound;
sType = (PsiClassType)PsiUtil.captureToplevelWildcards(upperBound, ((PsiCapturedWildcardType)myS).getContext());
}
}
@@ -0,0 +1,14 @@
import java.util.List;
class Test {
void f(List<? extends I<?>> list) {
foo(list.get(0));
}
private <T> T foo(I<T> id) {
return null;
}
interface I<Z> {
}
}
@@ -472,6 +472,10 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase
doTest();
}
public void testCapturedConversionDuringDirectSuperCheck() throws Exception {
doTest();
}
private void doTest() throws Exception {
doTest(false);
}