Files
openide/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/overloadResolution/PreferDefaultMethodsOverStatic.java
Mikhail Pyltsin 26de6fc1df [java-highlighting] WIP IDEA-372969 Support JEP 512: Compact Source Files and Instance Main Methods
- update language levels partially
- fix tests

(cherry picked from commit 8d7b599772eda8dfd999bee9f816ec2609be4adb)


(cherry picked from commit 98a507ba78b8fc496651b5800fc3936c9c87b689)

IJ-MR-169535

GitOrigin-RevId: 898e8b4dfc303eb60da6cfff5d756304c461c424
2025-08-04 12:58:49 +00:00

45 lines
1.1 KiB
Java

class Test {
interface I {
default void f() {}
}
interface J {
static void f() {}
}
static class IJ implements I, J {}
static class JI implements J, I {}
public static void main() {
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("");
j.<error descr="Static method may only be called on its containing interface">j</error>("");
}
}