wildcard substitution partly reverted (IDEA-122700)

This commit is contained in:
Anna Kozlova
2014-03-24 20:08:46 +01:00
parent b500c13eb0
commit 40424a1615
7 changed files with 36 additions and 6 deletions

View File

@@ -394,7 +394,7 @@ public class PsiSubstitutorImpl implements PsiSubstitutor {
if (erasure != null) {
final PsiType[] boundTypes = typeParameter.getExtendsListTypes();
for (PsiType boundType : boundTypes) {
if (TypeConversionUtil.isAssignable(boundType, erasure) || TypeConversionUtil.isAssignable(erasure, boundType)) {
if (TypeConversionUtil.isAssignable(erasure, boundType)) {
return boundType;
}
}

View File

@@ -311,7 +311,7 @@ class WithingBounds {
A<A<<error descr="Type parameter 'A' is not within its bound; should extend 'A<A>'">A</error>>> a3;
A<? extends A> a4;
A<<error descr="Type parameter '? super A' is not within its bound; should extend 'A<A<T>>'">? super A</error>> a5;
A<<error descr="Type parameter '? super A' is not within its bound; should extend 'A<? super A>'">? super A</error>> a5;
A<<error descr="Type parameter 'A[]' is not within its bound; should extend 'A<A[]>'">A[]</error>> a7;
}
}

View File

@@ -20,7 +20,7 @@ class Bug2<T extends Integer>{
}
void bug1(Parametrized<? super T> param) {
foo(param);
<error descr="Inferred type 'capture<? super T>' for type parameter 'I' is not within its bound; should extend 'java.lang.Number'">foo(param)</error>;
}
@@ -47,7 +47,7 @@ class Test {
}
void bug1(Parametrized<? super T> param) {
<error descr="Inferred type 'java.io.Serializable' for type parameter 'I' is not within its bound; should extend 'java.lang.Number'">foo(param)</error>;
<error descr="Inferred type 'capture<? super T>' for type parameter 'I' is not within its bound; should extend 'java.lang.Number'">foo(param)</error>;
}

View File

@@ -0,0 +1,26 @@
class Test {
class Event {}
class KeyEvent extends Event {
int getCode() {
return 0;
}
}
interface EventListener<T extends Event> {
void handle(T event);
}
class EventType<T extends Event>{}
static final EventType<KeyEvent> KEY_PRESSED = null;
{
addEventHandler(KEY_PRESSED, keyEvent -> {
int i = keyEvent.getCode();
});
}
public final <T extends Event> void addEventHandler(final EventType<T> eventType, final EventListener<? super T> listener) {}
}

View File

@@ -340,8 +340,6 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testIDEA120153() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); }
public void testIDEA120563() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); }
public void testSuperWildcardWithBoundPromotion() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false);}
public void testJavaUtilCollections_NoVerify() throws Exception {
PsiClass collectionsClass = getJavaFacade().findClass("java.util.Collections", GlobalSearchScope.moduleWithLibrariesScope(getModule()));
assertNotNull(collectionsClass);

View File

@@ -751,6 +751,8 @@ public class GenericsHighlighting8Test extends LightDaemonAnalyzerTestCase {
doTest();
}
public void testSuperWildcardWithBoundPromotion() { doTest();}
private void doTest() {
doTest(false);
}

View File

@@ -174,6 +174,10 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
doTest();
}
public void testIDEA122700() throws Exception {
doTest();
}
private void doTest() {
doTest(false);
}