normalize array of captures type (IDEA-211139)

GitOrigin-RevId: bfb2392bd4cd5e435ad6a3e8a825b068e17fb5fc
This commit is contained in:
Anna Kozlova
2019-04-28 14:45:38 +03:00
committed by intellij-monorepo-bot
parent 305fba4b65
commit 8e2bf508e0
4 changed files with 26 additions and 2 deletions
@@ -307,8 +307,10 @@ public class GenericsUtil {
if (refClass instanceof PsiAnonymousClass) {
type = ((PsiAnonymousClass)refClass).getBaseClassType();
}
if (type instanceof PsiCapturedWildcardType) {
type = ((PsiCapturedWildcardType)type).getUpperBound();
PsiType deepComponentType = type.getDeepComponentType();
if (deepComponentType instanceof PsiCapturedWildcardType) {
type = PsiTypesUtil.createArrayType(((PsiCapturedWildcardType)deepComponentType).getUpperBound(),
type.getArrayDimensions());
}
PsiType transformed = type.accept(new PsiTypeVisitor<PsiType>() {
@Override
@@ -0,0 +1,9 @@
interface I {}
abstract class Test<T extends I> {
void foo(Test<?> t) {
I[] m = t.get();
}
abstract T[] get();
}
@@ -0,0 +1,9 @@
interface I {}
abstract class Test<T extends I> {
void foo(Test<?> t) {
<selection>t.get()</selection>
}
abstract T[] get();
}
@@ -670,6 +670,10 @@ public class IntroduceVariableTest extends LightCodeInsightTestCase {
public void testCapturedWildcardUpperBoundSuggestedAsType() {
doTest(new MockIntroduceVariableHandler("m", false, false, false, "I"));
}
public void testArrayOfCapturedWildcardUpperBoundSuggestedAsType() {
doTest(new MockIntroduceVariableHandler("m", false, false, false, "I[]"));
}
public void testReturnNonExportedArray() {
doTest(new MockIntroduceVariableHandler("i", false, false, false, "java.io.File[]") {