mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-09 16:39:37 +07:00
method refs: ambiguity checks into resolver; testdata
This commit is contained in:
@@ -154,3 +154,32 @@ class MyTest5 {
|
||||
}
|
||||
}
|
||||
|
||||
public class MyTest6 {
|
||||
interface I {
|
||||
void _(Integer i);
|
||||
}
|
||||
|
||||
static void foo(Number i) {}
|
||||
static void foo(Integer i, String s) {}
|
||||
static void foo(Integer d) {}
|
||||
|
||||
public static void main(String[] args) {
|
||||
I s = MyTest6::foo;
|
||||
s._(1);
|
||||
}
|
||||
}
|
||||
|
||||
public class MyTest7 {
|
||||
interface I {
|
||||
void _(Number i);
|
||||
}
|
||||
|
||||
static void foo(Number i) {}
|
||||
static void foo(Integer i, String s) {}
|
||||
static void foo(Integer d) {}
|
||||
|
||||
public static void main(String[] args) {
|
||||
I s = MyTest7::foo;
|
||||
s._(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,4 +32,11 @@ class Test1 {
|
||||
interface Bar {
|
||||
Integer _(String s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Test2 {
|
||||
|
||||
void foo(Integer i) {}
|
||||
|
||||
<error descr="Incompatible types. Found: '<method reference>', required: 'java.lang.Object'">Object o = Test2::foo;</error>
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
class MyTest {
|
||||
|
||||
interface I {
|
||||
abstract void m1(int i);
|
||||
}
|
||||
|
||||
static class A {
|
||||
void m(int i) {}
|
||||
}
|
||||
|
||||
static class B extends A {
|
||||
void m(int i) {
|
||||
I mh = super::m;
|
||||
mh.m1(i);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
new B().m(10);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
class MyTest {
|
||||
|
||||
interface I {
|
||||
void _(MyTest receiver, Integer i);
|
||||
}
|
||||
|
||||
void m(Integer i) {}
|
||||
|
||||
public static void main(String[] args) {
|
||||
I i = MyTest :: m;
|
||||
i._(new MyTest(), 1);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user