mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-01 02:38:59 +07:00
lambda: effectively final
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
interface I {
|
||||
int m(int i);
|
||||
}
|
||||
interface J {
|
||||
int m();
|
||||
}
|
||||
|
||||
public class XXX {
|
||||
|
||||
@@ -19,4 +22,51 @@ public class XXX {
|
||||
final int L = 0;
|
||||
I i = (int h) -> { int k = 0; return h + k + <error descr="Variable used in lambda expression should be effectively final">j</error> + l + L; };
|
||||
}
|
||||
|
||||
void foo(J i) { }
|
||||
|
||||
void m1(int x) {
|
||||
int y = 1;
|
||||
foo(() -> x+y);
|
||||
}
|
||||
|
||||
void m2(int x) {
|
||||
int y;
|
||||
y = 1;
|
||||
foo(() -> x+y);
|
||||
}
|
||||
|
||||
void m3(int x, boolean cond) {
|
||||
int y;
|
||||
if (cond) y = 1;
|
||||
foo(() -> x+<error descr="Variable used in lambda expression should be effectively final">y</error>);
|
||||
}
|
||||
|
||||
void m4(int x, boolean cond) {
|
||||
int y;
|
||||
if (cond) y = 1;
|
||||
else y = 2;
|
||||
foo(() -> x+y);
|
||||
}
|
||||
|
||||
void m5(int x, boolean cond) {
|
||||
int y;
|
||||
if (cond) y = 1;
|
||||
y = 2;
|
||||
foo(() -> x+<error descr="Variable used in lambda expression should be effectively final">y</error>);
|
||||
}
|
||||
|
||||
void m6(int x) {
|
||||
foo(() -> <error descr="Variable used in lambda expression should be effectively final">x</error>+1);
|
||||
x++;
|
||||
}
|
||||
|
||||
void m7(int x) {
|
||||
foo(() -> <error descr="Variable used in lambda expression should be effectively final">x</error>=1);
|
||||
}
|
||||
|
||||
void m8() {
|
||||
int y;
|
||||
foo(() -> <error descr="Variable used in lambda expression should be effectively final">y</error>=1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user