mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-127637 code completion utility should strip 'extends' wildcards from generic qualifiers of generated anonymous classes
This commit is contained in:
@@ -476,6 +476,13 @@ public class GenericsUtil {
|
||||
PsiType substituted = resolveResult.getSubstitutor().substitute(typeParam);
|
||||
if (substituted instanceof PsiWildcardType) {
|
||||
substituted = ((PsiWildcardType)substituted).getBound();
|
||||
if (substituted instanceof PsiCapturedWildcardType) {
|
||||
PsiType bound = ((PsiCapturedWildcardType)substituted).getLowerBound();
|
||||
if (bound == null || bound == PsiType.NULL) {
|
||||
bound = ((PsiCapturedWildcardType)substituted).getUpperBound();
|
||||
}
|
||||
substituted = bound;
|
||||
}
|
||||
if (substituted == null) substituted = TypeConversionUtil.typeParameterErasure(typeParam);
|
||||
}
|
||||
map.put(typeParam, substituted);
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
class Main {
|
||||
void foo(List<? extends Number> list) {
|
||||
list.forEach(new Consumer<Number>() {
|
||||
@Override
|
||||
public void consume(Number number) {
|
||||
<caret>
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
class List<T> {
|
||||
void forEach(Consumer<? super T> consumer);
|
||||
}
|
||||
|
||||
interface Consumer<T> { void consume(T t); }
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
class Main {
|
||||
void foo(List<? extends Number> list) {
|
||||
list.forEach(new <caret>);
|
||||
}
|
||||
}
|
||||
|
||||
class List<T> {
|
||||
void forEach(Consumer<? super T> consumer);
|
||||
}
|
||||
|
||||
interface Consumer<T> { void consume(T t); }
|
||||
+4
-2
@@ -716,7 +716,7 @@ public class SmartTypeCompletionTest extends LightFixtureCompletionTestCase {
|
||||
public void testMethodColon() throws Exception { doFirstItemTest(':'); }
|
||||
public void testVariableColon() throws Exception { doFirstItemTest(':'); }
|
||||
|
||||
private void doFirstItemTest(char c) throws Exception {
|
||||
private void doFirstItemTest(char c) {
|
||||
configureByTestName();
|
||||
select(c);
|
||||
checkResultByTestName();
|
||||
@@ -824,6 +824,8 @@ public class SmartTypeCompletionTest extends LightFixtureCompletionTestCase {
|
||||
doActionTest();
|
||||
}
|
||||
|
||||
public void testDontSuggestWildcardGenerics() { doItemTest(); }
|
||||
|
||||
public void testCastWith2TypeParameters() throws Throwable { doTest(); }
|
||||
public void testClassLiteralInArrayAnnoInitializer() throws Throwable { doTest(); }
|
||||
public void testClassLiteralInArrayAnnoInitializer2() throws Throwable { doTest(); }
|
||||
@@ -1141,7 +1143,7 @@ public class SmartTypeCompletionTest extends LightFixtureCompletionTestCase {
|
||||
checkResultByTestName();
|
||||
}
|
||||
|
||||
private void doItemTest() throws Exception {
|
||||
private void doItemTest() {
|
||||
doFirstItemTest('\n');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user