mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-31 02:50:55 +07:00
Part of IDEA-326939 Support multi-pattern switch labels that define no variables GitOrigin-RevId: c236438af58e1c74a2bf12a5985b33cedadb9cbb
16 lines
602 B
Java
16 lines
602 B
Java
// "Replace 'switch' with 'if'" "true-preview"
|
|
abstract class Test {
|
|
abstract Object getObject();
|
|
|
|
void foo(Object o) {
|
|
<caret>switch (o) {
|
|
case null, String s -> System.out.println("one");
|
|
case Integer i when (i > 0) -> System.out.println("two");
|
|
case /*1*/Float/*2*/ /*3*/f when /*4*/ f > 5 && f < 10 -> System.out.println("two");
|
|
case Character c -> System.out.println(c);
|
|
case Double c -> System.out.println();
|
|
case Long _, StringBuilder _ when Math.random() > 0.5 -> System.out.println("long or stringbuilder, probably");
|
|
default -> {}
|
|
}
|
|
}
|
|
} |