inference: fix index for non-proper captured wildcard bounds (IDEA-188487)

This commit is contained in:
Anna.Kozlova
2018-03-19 17:48:41 +01:00
parent b91bb73dd2
commit 686c13fd01
3 changed files with 19 additions and 2 deletions
@@ -726,8 +726,11 @@ public class InferenceSession {
InferenceVariable[] variables = initBounds(null, restParamSubstitution, capturedParams.toArray(PsiTypeParameter.EMPTY_ARRAY));
int idx = 0;
for (PsiType parameter : parameters) {
if (parameter instanceof PsiCapturedWildcardType && isProperType(((PsiCapturedWildcardType)parameter).getWildcard())) {
variables[idx++].putUserData(ORIGINAL_CAPTURE, (PsiCapturedWildcardType)parameter);
if (parameter instanceof PsiCapturedWildcardType) {
InferenceVariable variable = variables[idx++];
if (isProperType(((PsiCapturedWildcardType)parameter).getWildcard())) {
variable.putUserData(ORIGINAL_CAPTURE, (PsiCapturedWildcardType)parameter);
}
}
}
return variables;
@@ -0,0 +1,13 @@
import java.util.Map;
class MyTest {
private static <T> Map<? super T, ? super String> foo() {
return null;
}
{
Map<? super Integer, ? super String> action2 = foo();
}
}
@@ -190,6 +190,7 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase
public void testIntersectionWithSameInterfaceButDifferentTypeArgument() { doTest(); }
public void testVarargsMethodPreferred() { doTest(); }
public void testSameNamedFreshVariables() { doTest(); }
public void testEnsureOrderOfFreshVariablesWhenCaptureNonProperTypes() { doTest(); }
public void testApplicabilityCheckFailsExpressionTypeCheckPasses() {
doTest();