method reference: preserve all conflicts to have navigation target

This commit is contained in:
Anna Kozlova
2015-12-10 12:52:02 +01:00
parent 65b5b7c840
commit a04d90243b
6 changed files with 11 additions and 8 deletions

View File

@@ -264,6 +264,9 @@ public class MethodReferenceResolver implements ResolveCache.PolyVariantContextR
return !firstCandidates.isEmpty() ? firstCandidates.get(0) : secondCandidates.get(0);
}
if (firstCandidates.isEmpty() && secondCandidates.isEmpty() && conflicts.size() > 1) {
return null;
}
conflicts.clear();
firstCandidates.addAll(secondCandidates);
conflicts.addAll(firstCandidates);

View File

@@ -27,7 +27,7 @@ class AlienTest {
static {
IInt i1 = MyTest::<error descr="Cannot resolve method 'abracadabra'">abracadabra</error>;
IInt i2 = MyTest::<error descr="Cannot resolve method 'foo'">foo</error>;
IInt i3 = MyTest::<error descr="Cannot resolve method 'bar'">bar</error>;
<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>
IInt i5 = <error descr="Non-static method cannot be referenced from a static context">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>;

View File

@@ -129,7 +129,7 @@ class MyTest4 {
}
{
bar(MyTest4:: <error descr="Cannot resolve method 'foo'">foo</error>);
bar<error descr="'bar(todelete.MyTest4.Bar1)' in 'todelete.MyTest4' cannot be applied to '(<method reference>)'">(MyTest4:: foo)</error>;
}
}

View File

@@ -16,7 +16,7 @@ class Test {
class Test1 {
{
Runnable b = Test1 :: <error descr="Cannot resolve method 'length'">length</error>;
<error descr="Incompatible types. Found: '<method reference>', required: 'java.lang.Runnable'">Runnable b = Test1 :: length;</error>
Comparable<String> c = Test1 :: length;
Comparable<Integer> c1 = Test1 :: length;
}

View File

@@ -145,7 +145,7 @@ class NonStaticInner3 {
}
{
I3<Foo> b1 = Foo::<error descr="Cannot resolve constructor 'Foo'">new</error>;
I4<Foo> b2 = Foo::<error descr="Cannot resolve constructor 'Foo'">new</error>;
<error descr="Incompatible types. Found: '<method reference>', required: 'NonStaticInner3.I3<NonStaticInner3.Foo>'">I3<Foo> b1 = Foo::new;</error>
<error descr="Incompatible types. Found: '<method reference>', required: 'NonStaticInner3.I4<NonStaticInner3.Foo>'">I4<Foo> b2 = Foo::new;</error>
}
}

View File

@@ -50,7 +50,7 @@ class MyTest {
I1 i1 = MyTest::static_1;
I1 i2 = MyTest::<error descr="Cannot resolve method 'static_2'">static_2</error>;
I1 i3 = MyTest::<error descr="Cannot resolve method 'static_3'">static_3</error>;
I1 i4 = MyTest::<error descr="Cannot resolve method 'static_4'">static_4</error>;
<error descr="Incompatible types. Found: '<method reference>', required: 'MyTest.I1'">I1 i4 = MyTest::static_4;</error>
}
@@ -58,12 +58,12 @@ class MyTest {
I1 i_1 = <error descr="Non-static method cannot be referenced from a static context">MyTest::_1</error>;
I1 i_2 = MyTest::<error descr="Cannot resolve method '_2'">_2</error>;
I1 i_3 = MyTest::<error descr="Cannot resolve method '_3'">_3</error>;
I1 i_4 = MyTest::<error descr="Cannot resolve method '_4'">_4</error>;
<error descr="Incompatible types. Found: '<method reference>', required: 'MyTest.I1'">I1 i_4 = MyTest::_4;</error>
I1 i1 = this::_1;
I1 i2 = this::<error descr="Cannot resolve method '_2'">_2</error>;
I1 i3 = this::<error descr="Cannot resolve method '_3'">_3</error>;
I1 i4 = this::<error descr="Cannot resolve method '_4'">_4</error>;
<error descr="Incompatible types. Found: '<method reference>', required: 'MyTest.I1'">I1 i4 = this::_4;</error>
I2 i21 = MyTest::<error descr="Cannot resolve method 'm1'">m1</error>;
I2 i22 = MyTest::<error descr="Cannot resolve method 'm2'">m2</error>;