Skip to content

Commit 742323c

Browse files
committed
[ASTScope] Eliminate getClosureIfClosureScope
... it's just a `dyn_cast` now.
1 parent 5c2171c commit 742323c

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

include/swift/AST/ASTScope.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,6 @@ class ASTScopeImpl : public ASTAllocated<ASTScopeImpl> {
233233
/// Determine the kind of scope node we have.
234234
ScopeKind getKind() const { return kind; }
235235

236-
virtual NullablePtr<AbstractClosureExpr> getClosureIfClosureScope() const;
237236
ASTContext &getASTContext() const;
238237
NullablePtr<Decl> getDeclIfAny() const;
239238
NullablePtr<Stmt> getStmtIfAny() const;
@@ -1161,9 +1160,6 @@ class ClosureParametersScope final : public ASTScopeImpl {
11611160
SourceRange
11621161
getSourceRangeOfThisASTNode(bool omitAssertions = false) const override;
11631162

1164-
NullablePtr<AbstractClosureExpr> getClosureIfClosureScope() const override {
1165-
return closureExpr;
1166-
}
11671163
Expr *getExpr() const { return closureExpr; }
11681164
bool ignoreInDebugInfo() const override { return true; }
11691165

lib/AST/ASTScope.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,11 @@ Pattern *AbstractPatternEntryScope::getPattern() const {
9898
}
9999

100100
NullablePtr<AbstractClosureExpr> BraceStmtScope::parentClosureIfAny() const {
101-
return !getParent() ? nullptr : getParent().get()->getClosureIfClosureScope();
102-
}
101+
if (auto parent = getParent()) {
102+
if (auto closureScope = dyn_cast<ClosureParametersScope>(parent.get()))
103+
return closureScope->closureExpr;
104+
}
103105

104-
NullablePtr<AbstractClosureExpr> ASTScopeImpl::getClosureIfClosureScope() const {
105106
return nullptr;
106107
}
107108

0 commit comments

Comments
 (0)