Files
openide/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/StaticInInner.java
Tagir Valeev 2072855222 IDEA-243546 Allow local interfaces and enums on language level 15-preview (part of JEP 384)
Also: fix non-static access checks for local interfaces/enums/records (JEP 384)
Also: i18n of error messages

GitOrigin-RevId: 40448f089229d77e32eb200b4011e1aea09391b0
2020-06-16 09:43:13 +03:00

115 lines
3.5 KiB
Java

//statics in inner
public class a {
static final Number x = null;
static final int ix = x== null ? 4 : 3;
class ic {
<error descr="Inner classes cannot have static declarations">static</error>
int i;
<error descr="Inner classes cannot have static declarations">static</error>
final int f1 = 3 < 4 ? (a.ix==5 ? 1 : 3) / 4 + 18 : 0;
<error descr="Inner classes cannot have static declarations">static</error>
final int f2 = x instanceof Integer ? 1 : 0;
<error descr="Inner classes cannot have static declarations">static</error>
class a_ic_c {}
<error descr="Inner classes cannot have static declarations">interface a_ic_i</error> {}
<error descr="Inner classes cannot have static declarations">static</error> interface a_ic_i2 {}
<error descr="Inner classes cannot have static declarations">static</error>
int a_ic_m(String s) { return 0; }
// static initializer
<error descr="Inner classes cannot have static declarations">static</error>
{}
}
interface ii {
static int i = 9;
void f();
// since nested interface is implicitly static:
static class ii_c {}
}
// static inside class inside code block
void f() {
class ic2 {
<error descr="Inner classes cannot have static declarations">static</error>
int i;
<error descr="Inner classes cannot have static declarations">static</error>
final int f1 = 3 < 4 ? (a.ix==5 ? 1 : 3) / 4 + 18 : 0;
<error descr="Inner classes cannot have static declarations">static</error>
final int f2 = x instanceof Integer ? 1 : 0;
<error descr="Inner classes cannot have static declarations"><error descr="Modifier 'static' not allowed here">static</error></error>
class a_ic_c2 {}
<error descr="Inner classes cannot have static declarations">static</error>
int a_ic_m2(String s) { return 0; }
// static initializer
<error descr="Inner classes cannot have static declarations">static</error>
{}
}
}
void f1()
{
new a() {
<error descr="Inner classes cannot have static declarations">static</error>
int i;
<error descr="Inner classes cannot have static declarations">static</error>
final int f1 = 3 < 4 ? (a.ix==5 ? 1 : 3) / 4 + 18 : 0;
// its not a compile time constant
<error descr="Inner classes cannot have static declarations">static</error>
final Object o = null;
<error descr="Inner classes cannot have static declarations">static</error>
final int f2 = x instanceof Integer ? 1 : 0;
<error descr="Inner classes cannot have static declarations"><error descr="Modifier 'static' not allowed here">static</error></error>
class a_ic_c2 {}
<error descr="Inner classes cannot have static declarations">static</error>
int a_ic_m2(String s) { return 0; }
// static initializer
<error descr="Inner classes cannot have static declarations">static</error>
{}
};
}
// local interface
class cc {
void f() {
<error descr="Local interfaces are not supported at language level '1.4'">interface</error> i {}
}
void ff() {
class inn {
<error descr="Inner classes cannot have static declarations">interface i</error> {}
}
}
Object o = new Runnable() {
<error descr="Inner classes cannot have static declarations">interface i</error> {}
public void run() {}
};
}
void withanonymous() {
new Object() {
<error descr="Modifier 'private' not allowed here">private</error> class RT {}
private void method() {}
private int myI;
};
}
}