@@ -440,18 +440,25 @@ class SwitchCase extends Stmt, @case {
440440 * Gets the expression on the right-hand side of the arrow, if any.
441441 *
442442 * Note, this predicate gets a value when this switch case is of the form
443- * `case e1 -> e2`, where `e2` is not a block. This predicate is mutually
444- * exclusive with `getRuleStatement`.
443+ * `case e1 -> e2`, where `e2` is neither a block nor a throw statement.
444+ * This predicate is mutually exclusive with `getRuleStatement`.
445445 */
446- Expr getRuleExpression ( ) { result .getParent ( ) = this and result .getIndex ( ) = - 1 }
446+ Expr getRuleExpression ( ) {
447+ result .getParent ( ) = this and result .getIndex ( ) = - 1
448+ or
449+ exists ( ExprStmt es | es .getParent ( ) = this and es .getIndex ( ) = - 1 | result = es .getExpr ( ) )
450+ }
447451
448452 /**
449453 * Gets the statement on the right-hand side of the arrow, if any.
450454 *
451455 * Note, this predicate gets a value when this switch case is of the form
452- * `case e1 -> { s1; s2; ... }`. This predicate is mutually exclusive with `getRuleExpression`.
456+ * `case e1 -> { s1; s2; ... }` or `case e1 -> throw ...`.
457+ * This predicate is mutually exclusive with `getRuleExpression`.
453458 */
454- Stmt getRuleStatement ( ) { result .getParent ( ) = this and result .getIndex ( ) = - 1 }
459+ Stmt getRuleStatement ( ) {
460+ result .getParent ( ) = this and result .getIndex ( ) = - 1 and not result instanceof ExprStmt
461+ }
455462}
456463
457464/** A constant `case` of a switch statement. */
0 commit comments