new inference: capture nested call case fixed (~Collections)

This commit is contained in:
Anna Kozlova
2014-03-21 12:45:29 +01:00
parent ccd70ec219
commit 9845ef2fd8
4 changed files with 20 additions and 8 deletions

View File

@@ -494,13 +494,6 @@ public class PsiImplUtil {
return PsiUtil.captureToplevelWildcards(type, expression);
}
final PsiElement parent = toplevel.getParent();
if (parent instanceof PsiExpressionList &&
PsiUtil.isLanguageLevel8OrHigher(parent) &&
parent.getParent() instanceof PsiCallExpression) {
return PsiUtil.captureToplevelWildcards(type, expression);
}
final PsiType normalized = doNormalizeWildcardByPosition(type, expression, toplevel);
LOG.assertTrue(normalized.isValid(), type);
if (normalized instanceof PsiClassType && !PsiUtil.isAccessedForWriting(toplevel)) {

View File

@@ -0,0 +1,15 @@
import java.util.Iterator;
class Test<K, V> {
private final Iterator<? extends Foo<? extends K, ? extends V>> i = null;
public Foo<K, V> next() {
return new Bar<>(i.next());
}
interface Foo<T, K> {}
private static class Bar<K, V> implements Foo<K, V> {
Bar(Foo<? extends K, ? extends V> e) {}
}
}

View File

@@ -142,7 +142,7 @@ class S1 {
}
void bar(List<? extends S1> k) {
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>>, capture<? extends 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>;
}
}

View File

@@ -747,6 +747,10 @@ public class GenericsHighlighting8Test extends LightDaemonAnalyzerTestCase {
doTest();
}
public void testCaptureInsideNestedCalls() throws Exception {
doTest();
}
private void doTest() {
doTest(false);
}