Skip to content

Commit f5557c4

Browse files
committed
Remove shouldWalkCaptureInitializerExpressions
There doesn't seem to be any reason we can't walk the PatternBindingDecls directly here.
1 parent 684621d commit f5557c4

File tree

4 files changed

+2
-32
lines changed

4 files changed

+2
-32
lines changed

include/swift/AST/ASTWalker.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -642,11 +642,6 @@ class ASTWalker {
642642
/// value of a property wrapper placeholder.
643643
virtual bool shouldWalkIntoPropertyWrapperPlaceholderValue() { return true; }
644644

645-
/// This method configures whether the walker should visit the capture
646-
/// initializer expressions within a capture list directly, rather than
647-
/// walking the declarations.
648-
virtual bool shouldWalkCaptureInitializerExpressions() { return false; }
649-
650645
/// This method configures whether the walker should exhibit the legacy
651646
/// behavior where accessors appear as peers of their storage, rather
652647
/// than children nested inside of it.

lib/AST/ASTWalker.cpp

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -977,17 +977,8 @@ class Traversal : public ASTVisitor<Traversal, Expr*, Stmt*,
977977

978978
Expr *visitCaptureListExpr(CaptureListExpr *expr) {
979979
for (auto c : expr->getCaptureList()) {
980-
if (Walker.shouldWalkCaptureInitializerExpressions()) {
981-
for (auto entryIdx : range(c.PBD->getNumPatternEntries())) {
982-
if (auto newInit = doIt(c.PBD->getInit(entryIdx)))
983-
c.PBD->setInit(entryIdx, newInit);
984-
else
985-
return nullptr;
986-
}
987-
} else {
988-
if (doIt(c.PBD))
989-
return nullptr;
990-
}
980+
if (doIt(c.PBD))
981+
return nullptr;
991982
}
992983

993984
AbstractClosureExpr *body = expr->getClosureBody();

lib/Sema/MiscDiagnostics.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,6 @@ static void diagSyntacticUseRestrictions(const Expr *E, const DeclContext *DC,
105105
return Action::Continue();
106106
}
107107

108-
bool shouldWalkCaptureInitializerExpressions() override { return true; }
109-
110108
PreWalkResult<Expr *> walkToExprPre(Expr *E) override {
111109
// See through implicit conversions of the expression. We want to be able
112110
// to associate the parent of this expression with the ultimate callee.
@@ -1579,8 +1577,6 @@ static void diagRecursivePropertyAccess(const Expr *E, const DeclContext *DC) {
15791577
cast<VarDecl>(DRE->getDecl())->isSelfParameter();
15801578
}
15811579

1582-
bool shouldWalkCaptureInitializerExpressions() override { return true; }
1583-
15841580
MacroWalking getMacroWalkingBehavior() const override {
15851581
return MacroWalking::Expansion;
15861582
}
@@ -2226,8 +2222,6 @@ static void diagnoseImplicitSelfUseInClosure(const Expr *E,
22262222
return parentContext->getInnermostClosureForSelfCapture();
22272223
}
22282224

2229-
bool shouldWalkCaptureInitializerExpressions() override { return true; }
2230-
22312225
bool shouldRecordClosure(const AbstractClosureExpr *E) {
22322226
// Record all closures in Swift 6 mode.
22332227
if (Ctx.isSwiftVersionAtLeast(6))
@@ -4560,8 +4554,6 @@ static void checkStmtConditionTrailingClosure(ASTContext &ctx, const Expr *E) {
45604554
public:
45614555
DiagnoseWalker(ASTContext &ctx) : Ctx(ctx) { }
45624556

4563-
bool shouldWalkCaptureInitializerExpressions() override { return true; }
4564-
45654557
MacroWalking getMacroWalkingBehavior() const override {
45664558
return MacroWalking::Expansion;
45674559
}
@@ -4685,8 +4677,6 @@ class ObjCSelectorWalker : public ASTWalker {
46854677
ObjCSelectorWalker(const DeclContext *dc, Type selectorTy)
46864678
: Ctx(dc->getASTContext()), DC(dc), SelectorTy(selectorTy) { }
46874679

4688-
bool shouldWalkCaptureInitializerExpressions() override { return true; }
4689-
46904680
MacroWalking getMacroWalkingBehavior() const override {
46914681
return MacroWalking::Expansion;
46924682
}
@@ -5547,8 +5537,6 @@ static void diagnoseUnintendedOptionalBehavior(const Expr *E,
55475537
}
55485538
}
55495539

5550-
bool shouldWalkCaptureInitializerExpressions() override { return true; }
5551-
55525540
MacroWalking getMacroWalkingBehavior() const override {
55535541
return MacroWalking::Expansion;
55545542
}
@@ -5622,8 +5610,6 @@ static void diagnoseDeprecatedWritableKeyPath(const Expr *E,
56225610
}
56235611
}
56245612

5625-
bool shouldWalkCaptureInitializerExpressions() override { return true; }
5626-
56275613
MacroWalking getMacroWalkingBehavior() const override {
56285614
return MacroWalking::Expansion;
56295615
}

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2905,8 +2905,6 @@ namespace {
29052905
llvm_unreachable("expected a CallExpr in applyStack!");
29062906
}
29072907

2908-
bool shouldWalkCaptureInitializerExpressions() override { return true; }
2909-
29102908
MacroWalking getMacroWalkingBehavior() const override {
29112909
return MacroWalking::Expansion;
29122910
}

0 commit comments

Comments
 (0)