mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-27 19:28:58 +07:00
- added condition for available feature GitOrigin-RevId: a8ae325cdd2843a932bf03fc535505a41865a9fb
65 lines
1.8 KiB
Java
65 lines
1.8 KiB
Java
// "Fix all 'Duplicate branches in 'switch'' problems in file" "true"
|
|
class C {
|
|
void foo(Object o) {
|
|
switch (o) {
|
|
case Integer _, String _ -> System.out.println(1); //can be merged
|
|
default -> System.out.println(2);
|
|
}
|
|
}
|
|
|
|
void foo2(Object o) {
|
|
switch (o) {
|
|
case Integer _ when o.hashCode() == 1 -> System.out.println(1);
|
|
case String _ -> System.out.println(1);
|
|
default -> System.out.println(2);
|
|
}
|
|
}
|
|
|
|
void foo3(Object o) {
|
|
switch (o) {
|
|
case Integer _, String _ when o.hashCode() == 1 -> System.out.println(1); //can be merged
|
|
default -> System.out.println(2);
|
|
}
|
|
}
|
|
|
|
void foo4(Object o) {
|
|
switch (o) {
|
|
case Integer _, String _ when o.hashCode() == 1 -> System.out.println(1); //can be merged
|
|
case Number s -> System.out.println(3);
|
|
default -> System.out.println(2);
|
|
}
|
|
}
|
|
|
|
void foo5(Object o) {
|
|
switch (o) {
|
|
case Integer _ when o.hashCode() == 1 -> System.out.println(1);
|
|
case Number s -> System.out.println(3);
|
|
case String _ when o.hashCode() == 2 -> System.out.println(1);
|
|
default -> System.out.println(2);
|
|
}
|
|
}
|
|
|
|
void foo6(Object o) {
|
|
switch (o) {
|
|
case Integer _ when o.hashCode() == 1 -> System.out.println(1);
|
|
case Number s -> System.out.println(3);
|
|
case String _ -> System.out.println(1);
|
|
default -> System.out.println(2);
|
|
}
|
|
}
|
|
|
|
void foo7(Object o) {
|
|
switch (o) {
|
|
case Integer _, String _ -> System.out.println(1); //can be merged
|
|
default -> System.out.println(2);
|
|
}
|
|
}
|
|
|
|
void foo8(Object o) {
|
|
switch (o) {
|
|
case Integer _, CharSequence _ when o.hashCode() == 1 -> System.out.println(1); //can be merged
|
|
case Number s -> System.out.println(3);
|
|
default -> System.out.println(2);
|
|
}
|
|
}
|
|
} |