Files
Mikhail Pyltsin 133cf1e8d2 [java-highlighting] IDEA-324705 Non-final variable in guard: provide a fix to rewrite 'if' statement
GitOrigin-RevId: 99770663b569ed2bd6a8d6452e5b0bbe923f9d15
2023-07-11 13:31:11 +00:00

13 lines
299 B
Java

// "Make 'mode' effectively final by moving initializer to the 'if' statement" "true-preview"
class Test {
void test(Object o) {
int mode = 2;
if (Math.random() > 0.5) {
mode = 3;
}
switch (o) {
case Integer i when i == mode<caret> -> {}
default -> {}
}
}
}