Distinguish record patterns that do or don't declare identifiers

This commit is contained in:
Chris Smowton
2024-03-25 16:20:36 +00:00
parent a4401963f5
commit 17193ac11b
2 changed files with 19 additions and 6 deletions

View File

@@ -2739,4 +2739,14 @@ class RecordPatternExpr extends Expr, @recordpatternexpr {
)
)
}
/**
* Holds if this record pattern declares any identifiers (i.e., at least one leaf declaration is named).
*/
predicate declaresAnyIdentifiers() {
exists(PatternExpr subPattern | subPattern = this.getSubPattern(_) |
subPattern.asRecordPattern().declaresAnyIdentifiers() or
not subPattern.asBindingOrUnnamedPattern().isAnonymous()
)
}
}