Files
Tagir Valeevandintellij-monorepo-bot a4f2bd1574 IDEA-380311 [java-highlighting] Invalid code "cannot referenced from static context" not highlighted properly in Java
(cherry picked from commit e1d8918aca30a74ffbf3d3bbf8af07c6f45b5244)

IJ-CR-194233

GitOrigin-RevId: f5918ea65adb2bf6ccae0835c52e826b88deb0ad
2026-03-04 10:47:55 +00:00

39 lines
774 B
Java

class A {
A(C c) {}
static class B extends A {
B() {
super(new <error descr="Cannot reference 'C' before superclass constructor is called">C</error>());
}
B(int x) {
super(<error descr="Non-static method 'getC()' cannot be referenced from a static context">getC</error>());
}
B(double x) {
super(<error descr="Non-static field 'c' cannot be referenced from a static context">c</error>);
}
}
class B1 extends A {
B1() {
super(new <error descr="Cannot reference 'C' before superclass constructor is called">C</error>());
}
B1(int x) {
super(getC());
}
B1(double x) {
super(c);
}
}
private C getC() {
return new C();
}
private C c = new C();
private class C {}
}