[java] raise error for void type expressions in switch (IDEA-278454)

GitOrigin-RevId: e44afc9d82e2e8211171fa5eb1b5dff90acab375
This commit is contained in:
Anna Kozlova
2021-09-20 09:06:29 +02:00
committed by intellij-monorepo-bot
parent 1cd8782c82
commit 0b768770f7
2 changed files with 16 additions and 1 deletions

View File

@@ -105,6 +105,11 @@ class MyTest {
Runnable r = () -> <error descr="Target type for switch expression cannot be void">switch</error>(0) {
default -> throw new IllegalArgumentException();
};
var rv = switch (0) {
case 0 -> 42;
default -> <error descr="Expression type should not be 'void'">System.out.println(42)</error>;
};
}
static void test(boolean b, int i) {