method references: show candidates if overload resolution failed (IDEA-148974)

This commit is contained in:
Anna Kozlova
2015-12-10 16:49:24 +01:00
parent a04d90243b
commit 3f72d428a8
28 changed files with 100 additions and 68 deletions

View File

@@ -26,8 +26,8 @@ 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>;
<error descr="Incompatible types. Found: '<method reference>', required: 'AlienTest.IInt'">IInt i3 = MyTest::bar;</error>
IInt i2 = <error descr="Bad return type in method reference: cannot convert void to int">MyTest::foo</error>;
IInt i3 = MyTest::<error descr="Cannot resolve method 'bar'">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

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

View File

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

View File

@@ -70,8 +70,8 @@ class MyTest3<X> {
static void test(I<Integer> s) { }
public static void main(String[] args) {
I<Integer> s = MyTest3<String>::<error descr="Cannot resolve constructor 'MyTest3'">new</error>;
test(MyTest3<String>::<error descr="Cannot resolve constructor 'MyTest3'">new</error>);
I<Integer> s = <error descr="Bad return type in method reference: cannot convert MyTest3<java.lang.String> to MyTest3<java.lang.Integer>">MyTest3<String>::new</error>;
test(<error descr="Bad return type in method reference: cannot convert MyTest3<java.lang.String> to MyTest3<java.lang.Integer>">MyTest3<String>::new</error>);
}
}

View File

@@ -71,7 +71,7 @@ class StaticInner1 {
static void call3(I2 s) {}
static {
call3<error descr="Ambiguous method call: both 'StaticInner1.call3(I1)' and 'StaticInner1.call3(I2)' match">(StaticInner1.Inner :: new)</error>;
call3(StaticInner1.Inner :: <error descr="Cannot resolve constructor 'Inner'">new</error>);
}
}
@@ -109,7 +109,7 @@ class NonStaticInner2 {
static {
I1 i1 = NonStaticInner2.Inner :: <error descr="Cannot resolve constructor 'Inner'">new</error>;
I1 i1 = <error descr="An enclosing instance of type NonStaticInner2 is not in scope">NonStaticInner2.Inner :: new</error>;
}
{
@@ -145,7 +145,7 @@ class NonStaticInner3 {
}
{
<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>
I3<Foo> b1 = Foo::<error descr="Cannot resolve constructor 'Foo'">new</error>;
I4<Foo> b2 = Foo::<error descr="Cannot resolve constructor 'Foo'">new</error>;
}
}

View File

@@ -49,7 +49,7 @@ class MyTestConstructor {
private static void <warning descr="Private method 'foo(MyTestConstructor.I3)' is never used">foo</warning>(I3 i) {System.out.println(i);}
static {
foo<error descr="Ambiguous method call: both 'MyTestConstructor.foo(I1)' and 'MyTestConstructor.foo(I2)' match">(Foo::new)</error>;
foo(Foo::<error descr="Cannot resolve constructor 'Foo'">new</error>);
}
}
@@ -78,6 +78,6 @@ class MyTestMethod {
private static void <warning descr="Private method 'foo(MyTestMethod.I3)' is never used">foo</warning>(I3 i) {System.out.println(i);}
static {
foo<error descr="Ambiguous method call: both 'MyTestMethod.foo(I1)' and 'MyTestMethod.foo(I2)' match">(MyTestMethod::m)</error>;
foo(MyTestMethod::<error descr="Cannot resolve method 'm'">m</error>);
}
}

View File

@@ -38,7 +38,7 @@ class MyTest1 {
}
public static void main(String[] args) {
call<error descr="Ambiguous method call: both 'MyTest1.call(int, I1)' and 'MyTest1.call(int, I2)' match">(1, MyTest1::m)</error>;
call(1, MyTest1::<error descr="Cannot resolve method 'm'">m</error>);
}
}
@@ -192,6 +192,6 @@ class MyTest9 {
void test() {
g1(MyTest9::m);
g2<error descr="Ambiguous method call: both 'MyTest9.g2(I1)' and 'MyTest9.g2(I2)' match">(MyTest9::m)</error>;
g2(MyTest9::<error descr="Cannot resolve method 'm'">m</error>);
}
}

View File

@@ -20,8 +20,8 @@ class MyTest {
static void foo(I3 i) {}
static {
foo<error descr="Ambiguous method call: both 'MyTest.foo(I1)' and 'MyTest.foo(I2)' match">(MyTest::m)</error>;
foo<error descr="Ambiguous method call: both 'MyTest.foo(I1)' and 'MyTest.foo(I2)' match">(MyTest::m1)</error>;
foo(MyTest::<error descr="Cannot resolve method 'm'">m</error>);
foo(MyTest::<error descr="Cannot resolve method 'm1'">m1</error>);
}
}
@@ -44,9 +44,9 @@ class MyTest1 {
static {
foo1(MyTest1::m);
foo2<error descr="Ambiguous method call: both 'MyTest1.foo2(I1)' and 'MyTest1.foo2(I2)' match">(MyTest1::m)</error>;
foo2(MyTest1::<error descr="Cannot resolve method 'm'">m</error>);
foo1(MyTest1::m1);
foo2<error descr="Ambiguous method call: both 'MyTest1.foo2(I1)' and 'MyTest1.foo2(I2)' match">(MyTest1::m1)</error>;
foo2(MyTest1::<error descr="Cannot resolve method 'm1'">m1</error>);
}
}

View File

@@ -12,7 +12,7 @@ class MyTest {
{
I i = Foo<String> :: foo;
I i1 = Foo<Integer> :: <error descr="Cannot resolve method 'foo'">foo</error>;
I i1 = <error descr="Non-static method cannot be referenced from a static context">Foo<Integer> :: foo</error>;
}
}
}

View File

@@ -39,6 +39,6 @@ class MyTest1 {
static void foo(I3 i) {}
static {
foo<error descr="Ambiguous method call: both 'MyTest1.foo(I1)' and 'MyTest1.foo(I2)' match">(Foo::new)</error>;
foo(Foo::<error descr="Cannot resolve constructor 'Foo'">new</error>);
}
}

View File

@@ -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(Foo::<error descr="Cannot resolve method 'm'">m</error>);
}
}
@@ -67,7 +67,7 @@ class MyTest1 {
}
public static void main(String[] args) {
m<error descr="Ambiguous method call: both 'MyTest1.m(I1)' and 'MyTest1.m(I2)' match">(Foo::new)</error>;
m(Foo::<error descr="Cannot resolve constructor 'Foo'">new</error>);
}
}
class MyTest2 {
@@ -104,6 +104,6 @@ class MyTest2 {
}
public static void main(String[] args) {
m<error descr="Ambiguous method call: both 'MyTest2.m(I1)' and 'MyTest2.m(I2)' match">(Foo::new)</error>;
m(Foo::<error descr="Cannot resolve constructor 'Foo'">new</error>);
}
}

View File

@@ -2,7 +2,7 @@ import java.util.*;
class LambdaTest {
public void testR() {
<error descr="Incompatible types. Found: 'java.lang.String', required: '<method reference>'">new ArrayList<String>() :: size = ""</error>;
new ArrayList<String>() :: <error descr="Cannot resolve method 'size'">size</error> = "";
}
}

View File

@@ -116,7 +116,7 @@ class MyTest2 {
static void call3(I2 s) {}
static {
call3(MyTest2::m1);
call3<error descr="Ambiguous method call: both 'MyTest2.call3(I1)' and 'MyTest2.call3(I2)' match">(MyTest2::m2)</error>;
call3(MyTest2::<error descr="Cannot resolve method 'm2'">m2</error>);
call3(MyTest2::m3);
call3<error descr="'call3(MyTest2.I2)' in 'MyTest2' cannot be applied to '(<method reference>)'">(MyTest2::m4)</error>;
}

View File

@@ -1,6 +1,6 @@
public class Test {
{
if (<error descr="Method reference expression is not expected here">Test::length instanceof String</error>) {
if (Test::<error descr="Cannot resolve method 'length'">length</error> instanceof String) {
}
bar(Test::length);
}

View File

@@ -50,20 +50,20 @@ 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>;
<error descr="Incompatible types. Found: '<method reference>', required: 'MyTest.I1'">I1 i4 = MyTest::static_4;</error>
I1 i4 = MyTest::<error descr="Cannot resolve method 'static_4'">static_4</error>;
}
{
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>;
<error descr="Incompatible types. Found: '<method reference>', required: 'MyTest.I1'">I1 i_4 = MyTest::_4;</error>
I1 i_2 = <error descr="Non-static method cannot be referenced from a static context">MyTest::_2</error>;
I1 i_3 = <error descr="Non-static method cannot be referenced from a static context">MyTest::_3</error>;
I1 i_4 = MyTest::<error descr="Cannot resolve method '_4'">_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>;
<error descr="Incompatible types. Found: '<method reference>', required: 'MyTest.I1'">I1 i4 = this::_4;</error>
I1 i4 = this::<error descr="Cannot resolve method '_4'">_4</error>;
I2 i21 = MyTest::<error descr="Cannot resolve method 'm1'">m1</error>;
I2 i22 = MyTest::<error descr="Cannot resolve method 'm2'">m2</error>;

View File

@@ -4,7 +4,7 @@ class Test {
void test() {
Comparator<Test> r2 = Test::yyy;
Comparator1<Test> c1 = <error descr="Non-static method cannot be referenced from a static context">Test::yyy</error>;
Comparator1<Test> c2 = Test::<error descr="Cannot resolve method 'xxx'">xxx</error>;
Comparator1<Test> c2 = <error descr="Non-static method cannot be referenced from a static context">Test::xxx</error>;
}
int yyy(Test... p) { return 1; }
int xxx(Test t) {return 42;}