mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-10 01:09:46 +07:00
lambda effectively final: ignore variables defined inside lambda (IDEA-89818)
This commit is contained in:
@@ -70,3 +70,24 @@ public class XXX {
|
||||
foo(() -> <error descr="Variable used in lambda expression should be effectively final">y</error>=1);
|
||||
}
|
||||
}
|
||||
|
||||
class Sample {
|
||||
public static void main(String[] args) {
|
||||
Runnable runnable = () -> {
|
||||
Integer i;
|
||||
if (true) {
|
||||
i = 111;
|
||||
System.out.println(i);
|
||||
}
|
||||
};
|
||||
|
||||
Runnable runnable2 = () -> {
|
||||
Integer i2 = 333;
|
||||
i2 = 444;
|
||||
System.out.println(i2);
|
||||
};
|
||||
|
||||
runnable.run(); // prints 111
|
||||
runnable2.run(); // prints 444
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user