@@ -440,18 +440,25 @@ class SwitchCase extends Stmt, @case {
440
440
* Gets the expression on the right-hand side of the arrow, if any.
441
441
*
442
442
* 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`.
445
445
*/
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
+ }
447
451
448
452
/**
449
453
* Gets the statement on the right-hand side of the arrow, if any.
450
454
*
451
455
* 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`.
453
458
*/
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
+ }
455
462
}
456
463
457
464
/** A constant `case` of a switch statement. */
0 commit comments