new inference: method references: process varargs

This commit is contained in:
Anna Kozlova
2014-02-10 20:49:06 +01:00
parent cb5a0b729b
commit 2b5764d82a
7 changed files with 173 additions and 60 deletions

View File

@@ -52,10 +52,10 @@ class MyTest1 {
}
static void test2() {
<error descr="Incompatible types. Found: '<method reference>', required: 'MyTest1.I2'">I2 s1 = MyTest1 :: m1;</error>
call2<error descr="'call2(MyTest1.I2)' in 'MyTest1' cannot be applied to '(<method reference>)'">(MyTest1::m1)</error>;
<error descr="Incompatible types. Found: '<method reference>', required: 'MyTest1.I2'">I2 s2 = MyTest1 :: m2;</error>
call2<error descr="'call2(MyTest1.I2)' in 'MyTest1' cannot be applied to '(<method reference>)'">(MyTest1::m2)</error>;
I2 s1 = MyTest1 :: m1;
call2(MyTest1::m1);
I2 s2 = MyTest1 :: m2;
call2(MyTest1::m2);
<error descr="Incompatible types. Found: '<method reference>', required: 'MyTest1.I2'">I2 s3 = MyTest1 :: m3;</error>
call2<error descr="'call2(MyTest1.I2)' in 'MyTest1' cannot be applied to '(<method reference>)'">(MyTest1::m3)</error>;
@@ -101,10 +101,10 @@ class MyTest2 {
}
static void test2() {
<error descr="Incompatible types. Found: '<method reference>', required: 'MyTest2.I2'">I2 s1 = MyTest2 :: m1;</error>
call2<error descr="'call2(MyTest2.I2)' in 'MyTest2' cannot be applied to '(<method reference>)'">(MyTest2::m1)</error>;
<error descr="Incompatible types. Found: '<method reference>', required: 'MyTest2.I2'">I2 s2 = MyTest2 :: m2;</error>
call2<error descr="'call2(MyTest2.I2)' in 'MyTest2' cannot be applied to '(<method reference>)'">(MyTest2::m2)</error>;
I2 s1 = MyTest2 :: m1;
call2(MyTest2::m1);
I2 s2 = MyTest2 :: m2;
call2(MyTest2::m2);
<error descr="Incompatible types. Found: '<method reference>', required: 'MyTest2.I2'">I2 s3 = MyTest2 :: m3;</error>
call2<error descr="'call2(MyTest2.I2)' in 'MyTest2' cannot be applied to '(<method reference>)'">(MyTest2::m3)</error>;
@@ -115,8 +115,8 @@ class MyTest2 {
static void call3(I1 s) {}
static void call3(I2 s) {}
static {
call3<error descr="Cannot resolve method 'call3(<method reference>)'">(MyTest2::m1)</error>;
call3<error descr="Cannot resolve method 'call3(<method reference>)'">(MyTest2::m2)</error>;
call3<error descr="Ambiguous method call: both 'MyTest2.call3(I1)' and 'MyTest2.call3(I2)' match">(MyTest2::m1)</error>;
call3<error descr="Ambiguous method call: both 'MyTest2.call3(I1)' and 'MyTest2.call3(I2)' match">(MyTest2::m2)</error>;
call3<error descr="Cannot resolve method 'call3(<method reference>)'">(MyTest2::m3)</error>;
call3<error descr="Cannot resolve method 'call3(<method reference>)'">(MyTest2::m4)</error>;
}

View File

@@ -0,0 +1,55 @@
class Main {
<T, R, P> Collector<T, R> m(Supplier<? extends R> supplier, BiConsumer<R, T, P> accumulator) {
return null;
}
Collector<String, Main> test2(Supplier<Main> sb) {
return m(sb, Main::append);
}
public Main append(String... str) {
return this;
}
interface Supplier<T> {
public T get();
}
interface Collector<T, R> {
}
interface BiConsumer<T, U, P> {
void accept(T t);
}
}
class Main1 {
<T, R, P> Collector<T, R> m(Supplier<? extends R> supplier, BiConsumer<R, T, P> accumulator) {
return null;
}
Collector<String, Main1> test2(Supplier<Main1> sb) {
return m(sb, Main1::append);
}
public Main1 append(Main1... str) {
return this;
}
interface Supplier<T> {
public T get();
}
interface Collector<T, R> {
}
interface BiConsumer<T, U, P> {
void accept(T t);
}
}

View File

@@ -2,7 +2,7 @@ import java.util.*;
class Test {
void test() {
<error descr="Incompatible types. Found: '<method reference>', required: 'java.util.Comparator<Test>'">Comparator<Test> r2 = Test::yyy;</error>
Comparator<Test> r2 = Test::yyy;
Comparator1<Test> c1 = <error descr="Non-static method cannot be referenced from a static context">Test::yyy</error>;
<error descr="Incompatible types. Found: '<method reference>', required: 'Comparator1<Test>'">Comparator1<Test> c2 = Test::xxx;</error>
}

View File

@@ -54,6 +54,6 @@ class Test {
Test s2 = staticCall<error descr="Ambiguous method call: both 'Test.staticCall(I1<String & Test>)' and 'Test.staticCall(I2<Test,String>)' match">(Test::n1)</error>;
Test s3 = staticCall(<error descr="Non-static method cannot be referenced from a static context">Test::n2</error>);
Test s4 = staticCall<error descr="Ambiguous method call: both 'Test.staticCall(I1<Test>)' and 'Test.staticCall(I2<Test,String>)' match">(Test::n01)</error>;
Test s5 = staticCall<error descr="Cannot resolve method 'staticCall(<method reference>)'">(Test::n012)</error>;
Test s5 = staticCall<error descr="Ambiguous method call: both 'Test.staticCall(I1<Test>)' and 'Test.staticCall(I2<Test,String>)' match">(Test::n012)</error>;
}
}