mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 21:11:28 +07:00
method refs: compilation error when static method is accept through instance reference
This commit is contained in:
@@ -420,7 +420,7 @@ public class PsiMethodReferenceExpressionImpl extends PsiReferenceExpressionBase
|
||||
final boolean staticOrValidConstructorRef = psiMethod.hasModifierProperty(PsiModifier.STATIC) || validConstructorRef;
|
||||
|
||||
if ((parameterTypes.length == signatureParameterTypes2.length || varArgs) &&
|
||||
(!myBeginsWithReferenceType || staticOrValidConstructorRef || (psiMethod.isConstructor() && conflict.isStaticsScopeCorrect()))) {
|
||||
(!(myBeginsWithReferenceType ^ staticOrValidConstructorRef) || (psiMethod.isConstructor() && conflict.isStaticsScopeCorrect()))) {
|
||||
boolean correct = true;
|
||||
for (int i = 0; i < parameterTypes.length; i++) {
|
||||
final PsiType type1 = subst.substitute(GenericsUtil.eliminateWildcards(parameterTypes[i]));
|
||||
|
||||
@@ -30,7 +30,7 @@ class AlienTest {
|
||||
<error descr="Incompatible types. Found: '<method reference>', required: 'AlienTest.IInt'">IInt i3 = MyTest::bar;</error>
|
||||
<error descr="Incompatible types. Found: '<method reference>', required: 'AlienTest.IIntInt'">IIntInt i4 = MyTest::bar;</error>
|
||||
<error descr="Incompatible types. Found: '<method reference>', required: 'AlienTest.IInt'">IInt i5 = MyTest::baz;</error>
|
||||
IInt i6 = <error descr="'foo(int)' is not public in 'MyTest.Foo'. Cannot be accessed from outside package">MyTest.foo::foo</error>;
|
||||
<error descr="Incompatible types. Found: '<method reference>', required: 'AlienTest.IInt'">IInt i6 = MyTest.foo::foo;</error>
|
||||
IInt i7 = MyTest.<error descr="'MyTest.Foo' has private access in 'MyTest'">Foo</error>::foo;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ class MyTest3 {
|
||||
static void m() { }
|
||||
|
||||
public static void main(String[] args) {
|
||||
I s = new MyTest3()::m;
|
||||
<error descr="Incompatible types. Found: '<method reference>', required: 'MyTest3.I'">I s = new MyTest3()::m;</error>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
class Test<X> {
|
||||
|
||||
interface I {
|
||||
void _();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void test() {
|
||||
<error descr="Incompatible types. Found: '<method reference>', required: 'Test.I'">I i1 = Test<String>::foo;</error>
|
||||
I i2 = Test::foo;
|
||||
}
|
||||
|
||||
static void foo() { };
|
||||
}
|
||||
@@ -7,8 +7,8 @@ class Test<T> {
|
||||
Test test = new Test<String>();
|
||||
BlahBlah<String> blahBlah = test::<String>foo;
|
||||
BlahBlah<String> blahBlah1 = test::<String>foo1;
|
||||
BlahBlah<String> blahBlah2 = test::<String>foo2;
|
||||
BlahBlah<String> blahBlah3 = test::<String>foo3;
|
||||
<error descr="Incompatible types. Found: '<method reference>', required: 'BlahBlah<java.lang.String>'">BlahBlah<String> blahBlah2 = test::<String>foo2;</error>
|
||||
<error descr="Incompatible types. Found: '<method reference>', required: 'BlahBlah<java.lang.String>'">BlahBlah<String> blahBlah3 = test::<String>foo3;</error>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -188,6 +188,10 @@ public class MethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testStaticMethodOnTypedClassReference() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() throws Exception {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user