inference for ? super wildcard (IDEA-67744)

This commit is contained in:
anna
2013-07-17 20:21:09 +02:00
parent b1418932ee
commit 25b9cc4304
3 changed files with 15 additions and 1 deletions

View File

@@ -902,7 +902,7 @@ public class PsiResolveHelperImpl implements PsiResolveHelper {
PsiType substituted = argResult.getSubstitutor().substitute(typeParameter);
if (substituted != null) {
Pair<PsiType, ConstraintType> res = getSubstitutionForTypeParameterInner(
superSubstitutor.substitute(typeParameter), substituted, patternType, ConstraintType.EQUALS, depth + 1);
superSubstitutor.substitute(typeParameter), substituted, patternType, ConstraintType.EQUALS, depth);
if (res != null) return res;
}
}

View File

@@ -0,0 +1,13 @@
import java.util.List;
abstract class B {
abstract <T> T[] foo(List<? super List<T>> x);
abstract <T> T[] foo1(List<? extends List<T>> x);
abstract <T> T[] foo2(List<List<? super List<T>>> x);
void bar(List<List<?>> x, List<List<List<?>>> y){
foo(x) [0] = "";
foo1<error descr="'foo1(java.util.List<? extends java.util.List<T>>)' in 'B' cannot be applied to '(java.util.List<java.util.List<?>>)'">(x)</error> [0] = "";
foo2<error descr="'foo2(java.util.List<java.util.List<? super java.util.List<T>>>)' in 'B' cannot be applied to '(java.util.List<java.util.List<java.util.List<?>>>)'">(y)</error> [0] = "";
}
}

View File

@@ -297,6 +297,7 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testIDEA57325() { doTest5(false); }
public void testIDEA67835() { doTest5(false); }
public void testIDEA67744() { doTest5(false); }
public void testJavaUtilCollections_NoVerify() throws Exception {
PsiClass collectionsClass = getJavaFacade().findClass("java.util.Collections", GlobalSearchScope.moduleWithLibrariesScope(getModule()));