File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -591,6 +591,19 @@ class SyntacticElementTarget {
591591 expression.expression = expr;
592592 }
593593
594+ Pattern *getPattern () const {
595+ if (auto *pattern = getAsUninitializedVar ())
596+ return pattern;
597+
598+ if (isForInitialization ())
599+ return getInitializationPattern ();
600+
601+ if (kind == Kind::forEachPreamble)
602+ return forEachStmt.pattern ;
603+
604+ return nullptr ;
605+ }
606+
594607 void setPattern (Pattern *pattern) {
595608 if (kind == Kind::uninitializedVar) {
596609 assert (uninitializedVar.declaration .is <Pattern *>());
Original file line number Diff line number Diff line change @@ -337,8 +337,8 @@ SyntacticElementTarget::walk(ASTWalker &walker) const {
337337 SyntacticElementTarget result = *this ;
338338 switch (kind) {
339339 case Kind::expression: {
340- if (isForInitialization ()) {
341- if (auto *newPattern = getInitializationPattern () ->walk (walker)) {
340+ if (auto *pattern = getPattern ()) {
341+ if (auto *newPattern = pattern ->walk (walker)) {
342342 result.setPattern (newPattern);
343343 } else {
344344 return std::nullopt ;
You can’t perform that action at this time.
0 commit comments