mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-09 11:44:39 +07:00
- skip 'constant values' for switch expressions if they contain always failed methods GitOrigin-RevId: 1207911bd11f94f37293254fa609e47b42aa96e1
28 lines
580 B
Java
28 lines
580 B
Java
import org.jetbrains.annotations.Nullable;
|
|
|
|
class SkipSwitchExpressionWithThrow {
|
|
static boolean test(int x) {
|
|
return switch (x) {
|
|
case 404 -> false;
|
|
case 401 -> throw new RuntimeException();
|
|
case 403 -> throw new IllegalArgumentException();
|
|
default -> throw new IllegalStateException();
|
|
};
|
|
}
|
|
|
|
public enum Foo {
|
|
A, B
|
|
}
|
|
|
|
public static <R> R exception() {
|
|
throw new RuntimeException();
|
|
}
|
|
|
|
@Nullable
|
|
public static Object test2(Foo foo) {
|
|
return switch (foo) {
|
|
case A -> null;
|
|
case B -> exception();
|
|
};
|
|
}
|
|
} |