Files
openide/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/mustBeFinalJava10/afterInsideWhenExpression.java
Andrey.Cherkasov 1c11e442b0 [java-highlighting] Check if variable within pattern guard is effectively final
IDEA-301356

GitOrigin-RevId: 0b8146783be915b5a05a48801151bf64176e39d8
2022-09-08 14:33:39 +00:00

16 lines
426 B
Java

// "Move 'x' into anonymous object" "true-preview"
class Test {
void test(Object o) {
var ref = new Object() {
int x = 42;
};
switch (o) {
case null -> System.out.println(0);
case Integer i -> System.out.println(1);
case String s when s.length() == ref.x++ -> System.out.println(2);
default -> System.out.println(123);
}
}
}