test/langtools/tools/javac/switchexpr/ExpressionSwitchBreaks2.java
branchdatagramsocketimpl-branch
changeset 58678 9cf78a70fa4f
parent 53878 4584d0331318
child 58679 9c3209ff7550
equal deleted inserted replaced
58677:13588c901957 58678:9cf78a70fa4f
    10         LOOP: while (true) {
    10         LOOP: while (true) {
    11         OUTER: switch (i) {
    11         OUTER: switch (i) {
    12             case 0:
    12             case 0:
    13                 return switch (j) {
    13                 return switch (j) {
    14                     case 0:
    14                     case 0:
    15                         break "0-0";
    15                         yield "0-0";
    16                     case 1:
    16                     case 1:
    17                         break ; //error: missing value
    17                         break ; //error: missing value
    18                     case 2:
    18                     case 2:
    19                         break OUTER; //error: jumping outside of the switch expression
    19                         break OUTER; //error: jumping outside of the switch expression
    20                     case 3: {
    20                     case 3: {
    21                         int x = -1;
    21                         int x = -1;
    22                         x: switch (i + j) {
    22                         x: switch (i + j) {
    23                             case 0: break x; //error: cannot disambiguate, wrong type as well
    23                             case 0: break x;
    24                         }
    24                         }
    25                         break "X";
    25                         yield "X";
    26                     }
    26                     }
    27                     case 4: return "X"; //error: no returns from inside of the switch expression
    27                     case 4: return "X"; //error: no returns from inside of the switch expression
    28                     case 5: continue;   //error: no continue out of the switch expression
    28                     case 5: continue;   //error: no continue out of the switch expression
    29                     case 6: continue LOOP; //error: dtto, but with a label
    29                     case 6: continue LOOP; //error: dtto, but with a label
    30                     case 7: continue UNKNOWN; //error: unknown label
    30                     case 7: continue UNKNOWN; //error: unknown label
    31                     default: {
    31                     default: {
    32                         String x = "X";
    32                         String x = "X";
    33                         x: switch (i + j) {
    33                         x: switch (i + j) {
    34                             case 0: break ""; //error: cannot break from switch expression that is not immediatelly enclosing
    34                             case 0: yield ""; //error: cannot yield from switch expression that is not immediatelly enclosing
    35                         }
    35                         }
    36                         break "X";
    36                         yield "X";
    37                     }
    37                     }
    38                 };
    38                 };
    39             case 1:
    39             case 1:
    40                 break "1" + undef; //error: complex value and no switch expression
    40                 yield "1" + undef; //error: complex value and no switch expression
    41         }
    41         }
    42         }
    42         }
    43         j: print(switch (i) {
    43         j: print(switch (i) {
    44             default: break j; //error: "j" is ambiguous (expression/label)
    44             case 0: yield 0;
       
    45             default: break j;
    45         }, 0);
    46         }, 0);
    46         j2: print(switch (i) {
    47         j2: print(switch (i) {
       
    48             case 0: yield 0;
    47             default: break j2;
    49             default: break j2;
    48         }, 0);
    50         }, 0);
    49         return null;
    51         return null;
    50     }
    52     }
    51 
    53