mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 03:13:40 +07:00
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:
+25
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// "Replace with lambda" "false"
|
||||
class Test {
|
||||
private final int myId;
|
||||
|
||||
private final Runnable myModels = new Runnable() {
|
||||
private Comparable<String> myMapping = new Compa<caret>rable<String>() {
|
||||
@Override
|
||||
public String apply(final String s) {
|
||||
return myId;
|
||||
}
|
||||
};
|
||||
|
||||
public void run() {}
|
||||
};
|
||||
|
||||
public Test(final int i) {
|
||||
myId = i;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user