@@ -318,7 +318,7 @@ module AssignableInternal {
318318 TLocalVariableDefinition ( LocalVariableDeclExpr lvde ) {
319319 not lvde .hasInitializer ( ) and
320320 not exists ( getTupleSource ( TTupleAssignmentDefinition ( _, lvde ) ) ) and
321- not lvde instanceof TopLevelPatternDecl and
321+ not lvde instanceof LocalVariablePatternDecl and
322322 not lvde .isOutArgument ( )
323323 } or
324324 TImplicitParameterDefinition ( Parameter p ) {
@@ -337,7 +337,7 @@ module AssignableInternal {
337337 default = p .getDefaultValue ( )
338338 } or
339339 TAddressOfDefinition ( AddressOfExpr aoe ) or
340- TPatternDefinition ( TopLevelPatternDecl tlpd ) or
340+ TPatternDefinition ( LocalVariablePatternDecl lvpd ) or
341341 TAssignOperationDefinition ( AssignOperation ao ) {
342342 ao instanceof AssignCallExpr and not ao instanceof CompoundAssignmentOperatorCall
343343 or
@@ -750,24 +750,31 @@ module AssignableDefinitions {
750750 }
751751
752752 /**
753- * A local variable definition in a pattern, for example `x is int i`.
753+ * A local variable definition in a pattern, for example `int i` in ` x is int i`.
754754 */
755755 class PatternDefinition extends AssignableDefinition , TPatternDefinition {
756- TopLevelPatternDecl tlpd ;
756+ LocalVariablePatternDecl lvpd ;
757757
758- PatternDefinition ( ) { this = TPatternDefinition ( tlpd ) }
758+ PatternDefinition ( ) { this = TPatternDefinition ( lvpd ) }
759759
760760 /** Gets the element matches against this pattern. */
761- PatternMatch getMatch ( ) { result = tlpd .getMatch ( ) }
761+ PatternMatch getMatch ( ) { result = lvpd .getMatch ( ) }
762762
763763 /** Gets the underlying local variable declaration. */
764- LocalVariableDeclExpr getDeclaration ( ) { result = tlpd }
765-
766- override Expr getSource ( ) { result = this .getMatch ( ) .getExpr ( ) }
764+ LocalVariableDeclExpr getDeclaration ( ) { result = lvpd }
767765
768766 override string toString ( ) { result = this .getDeclaration ( ) .toString ( ) }
769767 }
770768
769+ /**
770+ * A local variable definition at the top level of a pattern.
771+ */
772+ class TopLevelPatternDefinition extends PatternDefinition {
773+ TopLevelPatternDefinition ( ) { lvpd .isTopLevel ( ) }
774+
775+ override Expr getSource ( ) { result = this .getMatch ( ) .getExpr ( ) }
776+ }
777+
771778 /**
772779 * An initializer definition for a field or a property, for example
773780 * line 2 in
0 commit comments