1 /*
   2  * @test /nodynamiccopyright/
   3  * @bug 8206986
   4  * @summary Verify behavior of not exhaustive switch expressions.
   5  * @compile/fail/ref=ExpressionSwitchNotExhaustive.out -XDrawDiagnostics ExpressionSwitchNotExhaustive.java
   6  */
   7 
   8 public class ExpressionSwitchNotExhaustive {
   9     private String print(int i) {
  10         return switch (i) {
  11             case 42 -> "42";
  12             case 43 -> "43";
  13         };
  14     }
  15     private String e(E e) {
  16         return switch (e) {
  17             case A -> "42";
  18         };
  19     }
  20     private String f(int i, E e) {
  21         return switch (i) {
  22             case 0:
  23                 String s;
  24                 switch (e) {
  25                     case A:
  26                         s = "42";
  27                         break;
  28                 }
  29                 yield s;
  30             default:
  31                 yield "43";
  32         };
  33     }
  34     enum E {
  35         A, B;
  36     }
  37 }