Files
openide/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlightingPatternsInSwitch/UnusedPatternVariable.java
Tagir Valeev d0cf7b359a [java] IDEA-345498 Remove explicit Java 20-preview support and parenthesized patterns
GitOrigin-RevId: 8d646035979e3ec0a7de3c6f58a4e6ec9967bdbd
2024-02-12 19:12:36 +00:00

26 lines
716 B
Java

class Test {
void insideSwitch(Object o) {
switch (o){
case /*unused*/ Object <warning descr="Pattern variable 's' is never used"><caret>s</warning> /*unused*/ -> System.out.println();
}
switch (o){
case Object s -> System.out.println(s);
}
switch (o) {
case Object s when s != null -> System.out.println();
default -> System.out.println();
}
}
void insideInstanceOf(Object o) {
if (o instanceof String s && s != null) {
System.out.println();
}
if (o instanceof String s) {
System.out.println(s);
}
if (o instanceof String <warning descr="Pattern variable 's' is never used">s</warning>) {
System.out.println();
}
}
}