ensure non-initialized fields used inside lambdas are rejected if lambda is inside class initializer only (IDEA-154305)

This commit is contained in:
Anna.Kozlova
2016-04-07 15:11:17 +02:00
parent 66a8aa11b8
commit 0ed05632ff
3 changed files with 60 additions and 2 deletions

View File

@@ -0,0 +1,35 @@
class Test {
protected final String init;
protected final Runnable foo = new Runnable() {
{
Runnable r = () -> {
new Runnable() {
{
System.out.println(<error descr="Variable 'init' might not have been initialized">init</error>);
}
@Override
public void run() {
}
};
};
}
@Override
public void run() {
}
};
public Test(String init) {
this.init = init;
}
private void createClass() {
new Thread() {
{
Runnable runnable1 = () -> System.out.println(init);
}
};
}
}