mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-04 04:09:09 +07:00
overload resolution: treat default methods as abstract; don't include static interface methods in conflict resolution when target expression type does not correspond to the containing interface (IDEA-146055)
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
|
||||
interface A<T> {
|
||||
void foo(T x);
|
||||
default void foo(String x) { }
|
||||
}
|
||||
|
||||
class C implements A<String> {
|
||||
@Override
|
||||
public void foo(String x) {
|
||||
A.super.foo<error descr="Ambiguous method call: both 'A.foo(String)' and 'A.foo(String)' match">(x)</error>;
|
||||
}
|
||||
}
|
||||
|
||||
interface A2<T> {
|
||||
Object foo(T x);
|
||||
default Integer foo(String <warning descr="Parameter 'x' is never used">x</warning>) { return null; }
|
||||
}
|
||||
|
||||
abstract class C2 {
|
||||
public void foo(A2<String> x) {
|
||||
x.foo<error descr="Ambiguous method call: both 'A2.foo(String)' and 'A2.foo(String)' match">("")</error>;
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,33 @@ class Test {
|
||||
public static void main(String[] args) {
|
||||
new IJ(). f();
|
||||
new JI(). f();
|
||||
|
||||
IJ.<error descr="Non-static method 'f()' cannot be referenced from a static context">f</error>();
|
||||
JI.<error descr="Non-static method 'f()' cannot be referenced from a static context">f</error>();
|
||||
|
||||
J.f();
|
||||
}
|
||||
}
|
||||
|
||||
class Test2 {
|
||||
interface I {
|
||||
static void f(String <warning descr="Parameter 's' is never used">s</warning>) {}
|
||||
}
|
||||
|
||||
interface J<T> {
|
||||
default void f(T <warning descr="Parameter 't' is never used">t</warning>) {}
|
||||
|
||||
//another pair
|
||||
default void j(T <warning descr="Parameter 't' is never used">t</warning>) {}
|
||||
static void j(String <warning descr="Parameter 's' is never used">s</warning>) {};
|
||||
}
|
||||
|
||||
static class IJ implements I, J<String> {}
|
||||
|
||||
public static void main(IJ s, J<String> j) {
|
||||
s.f("");
|
||||
|
||||
<error descr="Static method may be invoked on containing interface class only">j.j("");</error>
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user