Files
openide/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/interfaceMethods/StaticMethodCalls.java
Anna Kozlova 856ec460c6 overload resolution: detect qualifier of unqualified call by processDeclaration's source where candidate was found
conflict resolution for static methods of the interface found by inheritance and nesting

GitOrigin-RevId: b637b02de4f59010a138c66890d1efcbcd1d588d
2019-11-07 02:40:58 +00:00

79 lines
1.9 KiB
Java

class Bug {
interface Function<T, R> {
public R apply(T t);
static <K> Function<K, K> identity() {
return k -> k;
}
}
interface IFunction extends Function<Integer, Integer> {
static void a() {
Function<Integer, Integer> identity = <error descr="Static method may be invoked on containing interface class only">identity();</error>
}
}
public void foo() {
Function<Integer, Integer> f = Function.identity();
Function<Integer, Integer> g = <error descr="Static method may be invoked on containing interface class only">f.identity();</error>
Function<Integer, Integer> h = IFunction.<error descr="Static method may be invoked on containing interface class only">identity</error>();
}
}
class StaticMethodInterfaceExample {
interface X {}
interface MyInterface {
static void staticMethod() {}
}
static class MyImplementation implements MyInterface { }
public static class Usage {
public <T extends MyInterface> void doStuff() {
T.staticMethod();
}
public <T extends MyImplementation> void doStuff1() {
<error descr="Static method may be invoked on containing interface class only">T.staticMethod();</error>
}
public <T extends MyInterface & X> void doStuff2() {
<error descr="Static method may be invoked on containing interface class only">T.staticMethod();</error>
}
public <T extends MyImplementation & MyInterface> void doStuff3() {
<error descr="Static method may be invoked on containing interface class only">T.staticMethod();</error>
}
}
}
class StaticMethodInterfaceExample2 {
interface MyInterface {
static void m(int a) { }
}
class MyClass {
void m() { }
class MyInnerClass implements MyInterface {
{
m();
}
}
}
}
interface StaticMethodInterfaceExample3 {
static void m() { }
class MyClass implements StaticMethodInterfaceExample3 {
{
m();
}
}
}