mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
introduce variable: suggest upper bound of captured wildcard
This commit is contained in:
@@ -298,7 +298,7 @@ public class GenericsUtil {
|
||||
public static PsiType getVariableTypeByExpressionType(@Nullable PsiType type, final boolean openCaptured) {
|
||||
if (type == null) return null;
|
||||
if (type instanceof PsiCapturedWildcardType) {
|
||||
type = ((PsiCapturedWildcardType)type).getWildcard();
|
||||
type = ((PsiCapturedWildcardType)type).getUpperBound();
|
||||
}
|
||||
PsiType transformed = type.accept(new PsiTypeVisitor<PsiType>() {
|
||||
@Override
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
interface I {}
|
||||
|
||||
abstract class Test<T extends I> {
|
||||
void foo(Test<?> t) {
|
||||
I m = t.get();
|
||||
}
|
||||
|
||||
abstract T get();
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
interface I {}
|
||||
|
||||
abstract class Test<T extends I> {
|
||||
void foo(Test<?> t) {
|
||||
<selection>t.get()</selection>
|
||||
}
|
||||
|
||||
abstract T get();
|
||||
}
|
||||
@@ -520,6 +520,10 @@ public class IntroduceVariableTest extends LightCodeInsightTestCase {
|
||||
doTest(new MockIntroduceVariableHandler("m", false, false, false, "java.util.function.IntFunction<java.lang.Class<?>[]>"));
|
||||
}
|
||||
|
||||
public void testCapturedWildcardUpperBoundSuggestedAsType() throws Exception {
|
||||
doTest(new MockIntroduceVariableHandler("m", false, false, false, "I"));
|
||||
}
|
||||
|
||||
public void testReturnNonExportedArray() {
|
||||
doTest(new MockIntroduceVariableHandler("i", false, false, false, "java.io.File[]") {
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user