Skip to content

Commit 2a5f29c

Browse files
committed
Swift: remove getIdentityPreservingEnclosingPattern
The Pattern public interface doesn't really need it.
1 parent 9461432 commit 2a5f29c

File tree

2 files changed

+5
-21
lines changed

2 files changed

+5
-21
lines changed

swift/ql/lib/codeql/swift/dataflow/internal/DataFlowPrivate.qll

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,11 @@ private module Cached {
192192
)
193193
or
194194
// flow from Pattern to an identity-preserving sub-Pattern:
195-
nodeFrom.asPattern() = nodeTo.asPattern().getIdentityPreservingEnclosingPattern()
195+
nodeTo.asPattern() =
196+
[
197+
nodeFrom.asPattern().(IsPattern).getSubPattern(),
198+
nodeFrom.asPattern().(TypedPattern).getSubPattern()
199+
]
196200
or
197201
// flow through a flow summary (extension of `SummaryModelCsv`)
198202
FlowSummaryImpl::Private::Steps::summaryLocalStep(nodeFrom, nodeTo, true)

swift/ql/lib/codeql/swift/elements/pattern/Pattern.qll

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,6 @@ class Pattern extends Generated::Pattern {
8585
result = this.getFullyUnresolved().(Pattern).getImmediateEnclosingPattern()
8686
}
8787

88-
/**
89-
* Gets the parent pattern of this pattern, but only if
90-
* both patterns match against the same object, which is not
91-
* the case when destructuring a complex data structure,
92-
* like a tuple or enum.
93-
*/
94-
final Pattern getIdentityPreservingEnclosingPattern() {
95-
result = this.getFullyUnresolved().(Pattern).getImmediateIdentityPreservingEnclosingPattern()
96-
}
97-
9888
/**
9989
* Gets the parent pattern of this pattern, if any.
10090
*/
@@ -105,16 +95,6 @@ class Pattern extends Generated::Pattern {
10595
or
10696
this = result.(TuplePattern).getImmediateElement(_)
10797
or
108-
result = this.getImmediateIdentityPreservingEnclosingPattern()
109-
}
110-
111-
/**
112-
* Gets the immediate parent pattern of this pattern, but only if
113-
* both patterns match against the same object, which is not
114-
* the case when destructuring a complex data structure,
115-
* like a tuple or enum.
116-
*/
117-
Pattern getImmediateIdentityPreservingEnclosingPattern() {
11898
this = result.(BindingPattern).getImmediateSubPattern()
11999
or
120100
this = result.(IsPattern).getImmediateSubPattern()

0 commit comments

Comments
 (0)