@@ -957,33 +957,20 @@ private module ControlFlowGraphImpl {
957957 not completion instanceof NormalOrBooleanCompletion
958958 )
959959 or
960- // the last node in a case rule in statement context is the last node in the right-hand side.
961- // If the rhs is a statement, we wrap the completion as a break.
962- exists ( Completion caseCompletion , SwitchStmt parent , SwitchCase case |
960+ exists ( Completion caseCompletion , SwitchCase case |
963961 case = n and
964- case = parent .getACase ( ) and
965- last ( case .getRuleStatementOrExpressionStatement ( ) , last , caseCompletion ) and
966- if caseCompletion instanceof NormalOrBooleanCompletion
967- then completion = anonymousBreakCompletion ( )
968- else completion = caseCompletion
969- )
970- or
971- // ...and when a switch occurs in expression context, we wrap the RHS in a yield statement.
972- // Note the wrapping can only occur in the expression case, because a statement would need
973- // to have explicit `yield` statements.
974- exists ( SwitchExpr parent , SwitchCase case |
975- case = n and
976- case = parent .getACase ( ) and
977962 (
978- exists ( Completion caseCompletion |
979- last ( case .getRuleExpression ( ) , last , caseCompletion ) and
980- if caseCompletion instanceof NormalOrBooleanCompletion
981- then completion = YieldCompletion ( caseCompletion )
982- else completion = caseCompletion
983- )
963+ last ( case .getRuleStatement ( ) , last , caseCompletion )
984964 or
985- last ( case .getRuleStatement ( ) , last , completion )
965+ last ( case .getRuleExpression ( ) , last , caseCompletion )
986966 )
967+ |
968+ if caseCompletion instanceof NormalOrBooleanCompletion
969+ then
970+ case .getParent ( ) instanceof SwitchStmt and completion = anonymousBreakCompletion ( )
971+ or
972+ case .getParent ( ) instanceof SwitchExpr and completion = YieldCompletion ( caseCompletion )
973+ else completion = caseCompletion
987974 )
988975 or
989976 // The normal last node in a non-rule pattern case is the last of its variable declaration(s),
0 commit comments