mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
new inference: captures should stay closed inside nested calls
This commit is contained in:
@@ -493,6 +493,13 @@ 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)) {
|
||||
|
||||
+1
-1
@@ -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>>, 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>>, capture<? extends S1>)'">(k, k.get(0))</error>;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
class Test {
|
||||
|
||||
class Foo<K> {}
|
||||
|
||||
void test(Foo<? extends String> p) {
|
||||
foo(bar(p)) ;
|
||||
}
|
||||
|
||||
<T> T bar(Foo<T> p) {
|
||||
return null;
|
||||
}
|
||||
|
||||
<K> K foo(K p) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+4
@@ -160,6 +160,10 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testLiftedCaptureToOuterCall() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() throws Exception {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user