IDEA-239116 Switch expression without any results is not highlighted as erroneous

GitOrigin-RevId: 66580d3aa4a95e1fdb32b1a3131544560c9c432a
This commit is contained in:
Tagir Valeev
2020-04-29 10:51:14 +00:00
committed by intellij-monorepo-bot
parent 5d753d02bd
commit b3ba7b6783
5 changed files with 74 additions and 11 deletions
@@ -28,13 +28,13 @@ class C {
}
void defaultBranchAlwaysThrows(int n) {
String s = switch (n) {
String s = <error descr="Switch expression does not have any result expressions">switch</error> (n) {
default: throw new RuntimeException();
};
}
void defaultRuleAlwaysThrows(int n) {
String s = switch (n) {
String s = <error descr="Switch expression does not have any result expressions">switch</error> (n) {
default -> throw new RuntimeException();
};
}
@@ -0,0 +1,18 @@
class Test {
void test() {
int i = <error descr="Switch expression does not have any result expressions">switch</error>(0) {
default -> throw new NullPointerException();
};
}
void test2() {
int i = <error descr="Switch expression does not have any result expressions">switch</error>(0) {
case 0 -> {while(true);}
case 1 -> {
throw new RuntimeException();
}
default -> throw new NullPointerException();
};
}
}