diff --git a/java/java-psi-api/src/com/intellij/psi/GenericsUtil.java b/java/java-psi-api/src/com/intellij/psi/GenericsUtil.java index 11028c056b74..06d40370d5b7 100644 --- a/java/java-psi-api/src/com/intellij/psi/GenericsUtil.java +++ b/java/java-psi-api/src/com/intellij/psi/GenericsUtil.java @@ -235,6 +235,11 @@ public class GenericsUtil { @Nullable public static PsiType getVariableTypeByExpressionType(@Nullable PsiType type) { + return getVariableTypeByExpressionType(type, true); + } + + @Nullable + public static PsiType getVariableTypeByExpressionType(@Nullable PsiType type, final boolean openCaptured) { if (type == null) return null; if (type instanceof PsiCapturedWildcardType) { type = ((PsiCapturedWildcardType)type).getWildcard(); @@ -274,7 +279,7 @@ public class GenericsUtil { @Override public PsiType visitCapturedWildcardType(PsiCapturedWildcardType capturedWildcardType) { - return capturedWildcardType; + return openCaptured ? capturedWildcardType.getWildcard().accept(this) : capturedWildcardType; } @Override diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiArrayAccessExpressionImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiArrayAccessExpressionImpl.java index cead445cb9b4..f9b2a939fa4b 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiArrayAccessExpressionImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiArrayAccessExpressionImpl.java @@ -46,7 +46,7 @@ public class PsiArrayAccessExpressionImpl extends ExpressionPsiElement implement public PsiType getType() { PsiType arrayType = getArrayExpression().getType(); if (!(arrayType instanceof PsiArrayType)) return null; - return GenericsUtil.getVariableTypeByExpressionType(((PsiArrayType)arrayType).getComponentType()); + return GenericsUtil.getVariableTypeByExpressionType(((PsiArrayType)arrayType).getComponentType(), false); } @Override diff --git a/java/java-tests/testSrc/com/intellij/refactoring/IntroduceVariableTest.java b/java/java-tests/testSrc/com/intellij/refactoring/IntroduceVariableTest.java index e7dcd5a8abe4..a447fa117790 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/IntroduceVariableTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/IntroduceVariableTest.java @@ -177,7 +177,7 @@ public class IntroduceVariableTest extends LightCodeInsightTestCase { } public void testSCR40281() throws Exception { - doTest(new MockIntroduceVariableHandler("temp", false, false, false, "Set.Entry,java.lang.String>>")); + doTest(new MockIntroduceVariableHandler("temp", false, false, false, "Set.Entry>")); } public void testWithIfBranches() throws Exception { @@ -189,7 +189,7 @@ public class IntroduceVariableTest extends LightCodeInsightTestCase { } public void testDuplicateGenericExpressions() throws Exception { - doTest(new MockIntroduceVariableHandler("temp", true, false, false, "Foo2>")); + doTest(new MockIntroduceVariableHandler("temp", true, false, false, "Foo2")); } public void testStaticImport() throws Exception { @@ -308,7 +308,7 @@ public class IntroduceVariableTest extends LightCodeInsightTestCase { } public void testAssignmentToUnresolvedReference() throws Exception { - doTest(new MockIntroduceVariableHandler("collection", true, true, true, "java.util.List>>")); + doTest(new MockIntroduceVariableHandler("collection", true, true, true, "java.util.List>")); } public void testNameSuggestion() throws Exception {