show error if uninitialized field is referenced from lambda inside inner/anonymous class in another field initializer; disable anonymous -> lambda for such places

This commit is contained in:
Anna.Kozlova
2016-03-21 21:11:36 +01:00
parent fb50cf14b5
commit 6fc9953a82
4 changed files with 48 additions and 1 deletions
@@ -64,3 +64,28 @@ abstract class TestInnerAnonymous {
}
}
interface Fun<A, B> {
B m(A a);
}
class TestAnonymousWithRefToTheTopLevelUninitializedField {
private final int myId;
private Runnable r = new Runnable() {
final int localId;
{
localId = 0;
}
Fun<Integer, Integer> ff = (a) -> <error descr="Variable 'myId' might not have been initialized">myId</error>;
Fun<Integer, Integer> ffLocal = (a) -> localId;
public void run() {
}
};
public TestAnonymousWithRefToTheTopLevelUninitializedField(int id) {
myId = id;
}
}