Skip to content

Commit a0c3286

Browse files
committed
[Sema] NFC: Clean up FindCapturedVars lazy init walking
We want to walk the lazy initializer in the accessor, but when this code was written that wasn't a walking option. Switch to using `LazyInitializerWalking::InAccessor`.
1 parent 55189ba commit a0c3286

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

lib/Sema/TypeCheckCaptures.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,9 @@ class FindCapturedVars : public ASTWalker {
241241
}
242242

243243
LazyInitializerWalking getLazyInitializerWalkingBehavior() override {
244-
// We don't want to walk into lazy initializers because they're not
245-
// really present at this level. We'll catch them when processing
246-
// the getter.
247-
return LazyInitializerWalking::None;
244+
// Captures for lazy initializers are computed as part of the parent
245+
// accessor.
246+
return LazyInitializerWalking::InAccessor;
248247
}
249248

250249
MacroWalking getMacroWalkingBehavior() const override {
@@ -643,12 +642,6 @@ class FindCapturedVars : public ASTWalker {
643642
if (auto *PEE = dyn_cast<PackElementExpr>(E))
644643
return walkToPackElementExpr(PEE);
645644

646-
// Look into lazy initializers.
647-
if (auto *LIE = dyn_cast<LazyInitializerExpr>(E)) {
648-
LIE->getSubExpr()->walk(*this);
649-
return Action::Continue(E);
650-
}
651-
652645
// When we see a reference to the 'super' expression, capture 'self' decl.
653646
if (auto *superE = dyn_cast<SuperRefExpr>(E)) {
654647
if (auto *selfDecl = superE->getSelf()) {

0 commit comments

Comments
 (0)