mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-20 13:31:28 +07:00
new inference: method refs: accept qualifier substitutor when nothing more could be inferred
This commit is contained in:
@@ -499,6 +499,7 @@ public class PsiMethodReferenceExpressionImpl extends PsiReferenceExpressionBase
|
||||
final PsiClass pClass = pResult.getElement();
|
||||
final PsiSubstitutor receiverSubstitutor = pClass != null ? TypeConversionUtil.getClassSubstitutor(containingClass, pClass, pResult.getSubstitutor()) : null;
|
||||
if (receiverSubstitutor != null) {
|
||||
if (!method.hasTypeParameters() && signature.getParameterTypes().length == 1) return receiverSubstitutor;
|
||||
psiSubstitutor = receiverSubstitutor;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ class MyTest {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
foo<error descr="Ambiguous method call: both 'MyTest.foo(I1)' and 'MyTest.foo(I2)' match">(Foo::m)</error>;
|
||||
foo<error descr="Ambiguous method call: both 'MyTest.foo(I2)' and 'MyTest.foo(I3)' match">(Foo::m)</error>;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
class Test {
|
||||
|
||||
static class Foo<X> {
|
||||
X m() { return null;}
|
||||
}
|
||||
|
||||
interface I {
|
||||
Foo<Object> _i(Foo<String> fs);
|
||||
}
|
||||
|
||||
static void foo(I i) { }
|
||||
{
|
||||
foo(<error descr="Bad return type in method reference: cannot convert java.lang.String to Test.Foo<java.lang.Object>">Foo::m</error>);
|
||||
}
|
||||
}
|
||||
@@ -173,6 +173,10 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testReturnTypeCheckForRawReceiver() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user