mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 00:11:26 +07:00
new inference: method references: process varargs
This commit is contained in:
+10
-10
@@ -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>;
|
||||
}
|
||||
|
||||
+55
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -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>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user