Skip to content

Commit 3616b6b

Browse files
committed
C#: Generalize pattern definition to not only include top level pattern definitions.
1 parent 8cae9d0 commit 3616b6b

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

‎csharp/ql/lib/semmle/code/csharp/Assignable.qll‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ module AssignableInternal {
321321
TLocalVariableDefinition(LocalVariableDeclExpr lvde) {
322322
not lvde.hasInitializer() and
323323
not exists(getTupleSource(TTupleAssignmentDefinition(_, lvde))) and
324-
not lvde instanceof TopLevelPatternDecl and
324+
not lvde instanceof LocalVariablePatternDecl and
325325
not lvde.isOutArgument()
326326
} or
327327
TImplicitParameterDefinition(Parameter p) {
@@ -340,7 +340,7 @@ module AssignableInternal {
340340
default = p.getDefaultValue()
341341
} or
342342
TAddressOfDefinition(AddressOfExpr aoe) or
343-
TPatternDefinition(TopLevelPatternDecl tlpd) or
343+
TPatternDefinition(LocalVariablePatternDecl lvpd) or
344344
TAssignOperationDefinition(AssignOperation ao) {
345345
ao instanceof AssignCallExpr and not ao instanceof CompoundAssignmentOperatorCall
346346
or
@@ -753,18 +753,18 @@ module AssignableDefinitions {
753753
}
754754

755755
/**
756-
* A local variable definition in a pattern, for example `x is int i`.
756+
* A local variable definition in a pattern, for example `int i` in `x is int i`.
757757
*/
758758
class PatternDefinition extends AssignableDefinition, TPatternDefinition {
759-
TopLevelPatternDecl tlpd;
759+
LocalVariablePatternDecl lvpd;
760760

761-
PatternDefinition() { this = TPatternDefinition(tlpd) }
761+
PatternDefinition() { this = TPatternDefinition(lvpd) }
762762

763763
/** Gets the element matches against this pattern. */
764-
PatternMatch getMatch() { result = tlpd.getMatch() }
764+
PatternMatch getMatch() { result = lvpd.getMatch() }
765765

766766
/** Gets the underlying local variable declaration. */
767-
LocalVariableDeclExpr getDeclaration() { result = tlpd }
767+
LocalVariableDeclExpr getDeclaration() { result = lvpd }
768768

769769
override Expr getSource() { result = this.getMatch().getExpr() }
770770

0 commit comments

Comments
 (0)