8212982: Rule cases in switch expression accepted even if complete normally

Ensure an error is reported if switch expression does not correctly produce a value.

Reviewed-by: mcimadamore
This commit is contained in:
Jan Lahoda 2018-11-21 15:22:57 +01:00
parent 9314c7f110
commit 60b32f222f
10 changed files with 280 additions and 55 deletions

View file

@ -46,7 +46,7 @@ public class ExpSwitchNestingTest extends JavacTemplateTestBase {
private static final String ESWITCH_S = "String res_string = switch (x) { case 0 -> { # } default -> \"default\"; };";
private static final String INT_FN_ESWITCH = "java.util.function.IntSupplier r = switch (x) { case 0 -> { # } default -> null; };";
private static final String INT_ESWITCH_DEFAULT = "int res = switch (x) { default -> { # } };";
private static final String IF = "if (cond) { # }";
private static final String IF = "if (cond) { # } else throw new RuntimeException();";
private static final String BLOCK = "{ # }";
private static final String BREAK_Z = "break 0;";
private static final String BREAK_S = "break \"hello world\";";