@@ -408,7 +408,7 @@ class SwitchStmt extends Stmt, @switchstmt {
408408 *
409409 * Note this may be `default` or `case null, default`.
410410 */
411- SwitchCase getDefaultCase ( ) { result = this .getACase ( ) and result . hasDefaultLabel ( ) }
411+ DefaultCase getDefaultCase ( ) { result = this .getACase ( ) }
412412
413413 /** Gets the expression of this `switch` statement. */
414414 Expr getExpr ( ) { result .getParent ( ) = this }
@@ -492,12 +492,6 @@ class SwitchCase extends Stmt, @case {
492492 Stmt getRuleStatementOrExpressionStatement ( ) {
493493 result .getParent ( ) = this and result .getIndex ( ) = - 1
494494 }
495-
496- /**
497- * Holds if this case statement includes the default label, i.e. it is either `default`
498- * or `case null, default`.
499- */
500- predicate hasDefaultLabel ( ) { this instanceof DefaultCase or this instanceof NullDefaultCase }
501495}
502496
503497/**
@@ -553,12 +547,14 @@ class PatternCase extends SwitchCase {
553547}
554548
555549/**
556- * A `default` case of a `switch` statement.
557- *
558- * Note this does not include `case null, default` -- for that, see `NullDefaultCase`.
550+ * A `default` or `case null, default` case of a `switch` statement or expression.
559551 */
560552class DefaultCase extends SwitchCase {
561- DefaultCase ( ) { not exists ( Expr e | e .getParent ( ) = this | e .getIndex ( ) >= 0 ) }
553+ DefaultCase ( ) {
554+ isNullDefaultCase ( this )
555+ or
556+ not exists ( Expr e | e .getParent ( ) = this | e .getIndex ( ) >= 0 )
557+ }
562558
563559 override string pp ( ) { result = "default" }
564560
@@ -570,7 +566,7 @@ class DefaultCase extends SwitchCase {
570566}
571567
572568/** A `case null, default` statement of a `switch` statement or expression. */
573- class NullDefaultCase extends SwitchCase {
569+ class NullDefaultCase extends DefaultCase {
574570 NullDefaultCase ( ) { isNullDefaultCase ( this ) }
575571
576572 override string pp ( ) { result = "case null, default" }
0 commit comments