IDEA-124019

This commit is contained in:
Anna Kozlova
2014-04-29 15:31:57 +04:00
parent 291c4310e6
commit f58394cd59
7 changed files with 25 additions and 13 deletions

View File

@@ -512,16 +512,16 @@ public class PsiOldInferenceHelper implements PsiInferenceHelper {
PsiType patternType,
final ConstraintType constraintType,
final int depth) {
if (patternType.equals(param)) {
return processArgType(arg, constraintType, depth < 2);
}
if (arg instanceof PsiCapturedWildcardType && (depth < 2 ||
constraintType != ConstraintType.EQUALS ||
param instanceof PsiWildcardType)) {
arg = ((PsiCapturedWildcardType)arg).getWildcard(); //reopen
}
if (patternType.equals(param)) {
return processArgType(arg, constraintType, depth < 2);
}
if (param instanceof PsiWildcardType) {
final PsiWildcardType wildcardParam = (PsiWildcardType)param;
final PsiType paramBound = wildcardParam.getBound();

View File

@@ -7,6 +7,6 @@ abstract class B {
}
void foo(Class<?> aClass) {
A a = <error descr="Inferred type '?' for type parameter 'T' is not within its bound; should extend 'A'">getA(aClass)</error>;
A a = <error descr="Inferred type 'capture<?>' for type parameter 'T' is not within its bound; should extend 'A'">getA(aClass)</error>;
}
}

View File

@@ -0,0 +1,11 @@
class Sample {
private <T> void collectClassInformation(java.util.Set<Class<? extends T>> classes) throws Exception {
for (Class<? extends T> root : classes) {
collectClassInformation<error descr="'collectClassInformation(java.util.Set<java.lang.Class<? extends T>>)' in 'Sample' cannot be applied to '(java.util.Set<java.lang.Class<capture<? extends T>>>)'">(getSubTypesOf(root))</error>;
}
}
public <T> java.util.Set<Class<? extends T>> getSubTypesOf(Class<T> type) {
return null;
}
}

View File

@@ -9,8 +9,8 @@ class B<L> {
void bar(B<?> b, A<?, ?> foo1) {
baz(b.foo());
A<?, ?> foo = b.foo();
baz<error descr="'baz(A<K,K>)' in 'B' cannot be applied to '(A<capture<?>,capture<?>>)'">(foo)</error>;
baz<error descr="'baz(A<K,K>)' in 'B' cannot be applied to '(A<capture<?>,capture<?>>)'">(foo1)</error>;
baz<error descr="'baz(A<capture<?>,capture<?>>)' in 'B' cannot be applied to '(A<capture<?>,capture<?>>)'">(foo)</error>;
baz<error descr="'baz(A<capture<?>,capture<?>>)' in 'B' cannot be applied to '(A<capture<?>,capture<?>>)'">(foo1)</error>;
}
<K> void baz(A<K, K> a) {

View File

@@ -1,6 +1,6 @@
class C<T extends C<? extends C<? extends T>>>{
void foo(C<?> x){
<error descr="Inferred type '? extends C<? extends C<capture<?>>>' for type parameter 'T' is not within its bound; should extend 'C<? extends C<? extends C<capture<?>>>>'">bar(x)</error>;
<error descr="Inferred type 'capture<? extends C<? extends C<capture<?>>>>' for type parameter 'T' is not within its bound; should extend 'C<capture<? extends C<? extends C<capture<?>>>>>'">bar(x)</error>;
}
<T extends C<? extends T>> void bar(C<T> x){}
}

View File

@@ -87,7 +87,7 @@ class CaptureTest {
}
void foo (Class<? extends Emum<CaptureTest>> clazz) {
<error descr="Inferred type '? extends CaptureTest.Emum<CaptureTest>' for type parameter 'T' is not within its bound; should extend 'CaptureTest.Emum<? extends CaptureTest.Emum<CaptureTest>>'">Emum.valueOf(clazz, "CCC")</error>;
<error descr="Inferred type 'capture<? extends CaptureTest.Emum<CaptureTest>>' for type parameter 'T' is not within its bound; should extend 'CaptureTest.Emum<capture<? extends CaptureTest.Emum<CaptureTest>>>'">Emum.valueOf(clazz, "CCC")</error>;
}
}
@@ -142,7 +142,7 @@ class S1 {
}
void bar(List<? extends S1> k) {
f<error descr="'f(java.util.List<S1>, S1)' in 'S1' cannot be applied to '(java.util.List<capture<? extends S1>>, S1)'">(k, k.get(0))</error>;
f<error descr="'f(java.util.List<capture<? extends S1>>, capture<? extends S1>)' in 'S1' cannot be applied to '(java.util.List<capture<? extends S1>>, S1)'">(k, k.get(0))</error>;
}
}
@@ -152,7 +152,7 @@ class S2 {
}
void bar(List<? extends S2> k) {
f<error descr="'f(java.util.List<T>, java.util.List<T>)' in 'S2' cannot be applied to '(java.util.List<capture<? extends S2>>, java.util.List<capture<? extends S2>>)'">(k, k)</error>;
f<error descr="'f(java.util.List<capture<? extends S2>>, java.util.List<capture<? extends S2>>)' in 'S2' cannot be applied to '(java.util.List<capture<? extends S2>>, java.util.List<capture<? extends S2>>)'">(k, k)</error>;
}
}
@@ -162,7 +162,7 @@ class S3 {
}
void bar(Map<? extends S3, ? extends S3> k) {
f<error descr="'f(java.util.Map<T,T>)' in 'S3' cannot be applied to '(java.util.Map<capture<? extends S3>,capture<? extends S3>>)'">(k)</error>;
f<error descr="'f(java.util.Map<capture<? extends S3>,capture<? extends S3>>)' in 'S3' cannot be applied to '(java.util.Map<capture<? extends S3>,capture<? extends S3>>)'">(k)</error>;
}
}
@@ -214,7 +214,7 @@ public static void foo(List<? extends Foo> foos) {
class OtherBug1 {
public static void foo(List<? super Foo> foos) {
final Comparator<Foo> comparator = createComparator();
Collections.sort<error descr="'sort(java.util.List<T>, java.util.Comparator<? super T>)' in 'java.util.Collections' cannot be applied to '(java.util.List<capture<? super OtherBug1.Foo>>, java.util.Comparator<OtherBug1.Foo>)'">(foos, comparator)</error>;
Collections.sort<error descr="'sort(java.util.List<capture<? super OtherBug1.Foo>>, java.util.Comparator<capture<? super OtherBug1.Foo>>)' in 'java.util.Collections' cannot be applied to '(java.util.List<capture<? super OtherBug1.Foo>>, java.util.Comparator<OtherBug1.Foo>)'">(foos, comparator)</error>;
}
private static Comparator<Foo> createComparator() {

View File

@@ -349,6 +349,7 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testIDEA123338() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); }
public void testIDEA124271() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); }
public void testIDEA124352() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); }
public void testIDEA124019() { 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()));