lambda effectively final: ignore variables defined inside lambda (IDEA-89818)

This commit is contained in:
Anna Kozlova
2012-08-07 19:24:25 +04:00
parent 4ab8573957
commit bee0bd2963
2 changed files with 22 additions and 1 deletions

View File

@@ -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
}
}