Skip to content

Commit 1caaeeb

Browse files
authored
Merge pull request #76295 from hamishknight/capturent
Remove `shouldWalkCaptureInitializerExpressions`
2 parents cc98822 + f5557c4 commit 1caaeeb

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.
@@ -1581,8 +1579,6 @@ static void diagRecursivePropertyAccess(const Expr *E, const DeclContext *DC) {
15811579
cast<VarDecl>(DRE->getDecl())->isSelfParameter();
15821580
}
15831581

1584-
bool shouldWalkCaptureInitializerExpressions() override { return true; }
1585-
15861582
MacroWalking getMacroWalkingBehavior() const override {
15871583
return MacroWalking::Expansion;
15881584
}
@@ -2228,8 +2224,6 @@ static void diagnoseImplicitSelfUseInClosure(const Expr *E,
22282224
return parentContext->getInnermostClosureForSelfCapture();
22292225
}
22302226

2231-
bool shouldWalkCaptureInitializerExpressions() override { return true; }
2232-
22332227
bool shouldRecordClosure(const AbstractClosureExpr *E) {
22342228
// Record all closures in Swift 6 mode.
22352229
if (Ctx.isSwiftVersionAtLeast(6))
@@ -4561,8 +4555,6 @@ static void checkStmtConditionTrailingClosure(ASTContext &ctx, const Expr *E) {
45614555
public:
45624556
DiagnoseWalker(ASTContext &ctx) : Ctx(ctx) { }
45634557

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

4689-
bool shouldWalkCaptureInitializerExpressions() override { return true; }
4690-
46914681
MacroWalking getMacroWalkingBehavior() const override {
46924682
return MacroWalking::Expansion;
46934683
}
@@ -5548,8 +5538,6 @@ static void diagnoseUnintendedOptionalBehavior(const Expr *E,
55485538
}
55495539
}
55505540

5551-
bool shouldWalkCaptureInitializerExpressions() override { return true; }
5552-
55535541
MacroWalking getMacroWalkingBehavior() const override {
55545542
return MacroWalking::Expansion;
55555543
}
@@ -5623,8 +5611,6 @@ static void diagnoseDeprecatedWritableKeyPath(const Expr *E,
56235611
}
56245612
}
56255613

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

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)