1 /*
2 * @test /nodynamiccopyright/
3 * @bug 8212982
4 * @summary Verify a compile-time error is produced if switch expression does not provide a value
5 * @compile/fail/ref=ExpressionSwitchFlow.out --enable-preview -source ${jdk.version} -XDrawDiagnostics ExpressionSwitchFlow.java
6 */
7
8 public class ExpressionSwitchFlow {
9 private String test1(int i) {
10 return switch (i) {
11 case 0 -> {}
12 default -> { yield "other"; }
13 };
14 }
15 private String test2(int i) {
16 return switch (i) {
17 case 0 -> {
18 }
19 default -> "other";
20 };
21 }
22 private String test3(int i) {
23 return switch (i) {
24 case 0 -> {}
25 case 1 -> "";
|
1 /*
2 * @test /nodynamiccopyright/
3 * @bug 8212982
4 * @summary Verify a compile-time error is produced if switch expression does not provide a value
5 * @compile/fail/ref=ExpressionSwitchFlow.out -XDrawDiagnostics ExpressionSwitchFlow.java
6 */
7
8 public class ExpressionSwitchFlow {
9 private String test1(int i) {
10 return switch (i) {
11 case 0 -> {}
12 default -> { yield "other"; }
13 };
14 }
15 private String test2(int i) {
16 return switch (i) {
17 case 0 -> {
18 }
19 default -> "other";
20 };
21 }
22 private String test3(int i) {
23 return switch (i) {
24 case 0 -> {}
25 case 1 -> "";
|