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 {
591
591
expression.expression = expr;
592
592
}
593
593
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
+
594
607
void setPattern (Pattern *pattern) {
595
608
if (kind == Kind::uninitializedVar) {
596
609
assert (uninitializedVar.declaration .is <Pattern *>());
Original file line number Diff line number Diff line change @@ -337,8 +337,8 @@ SyntacticElementTarget::walk(ASTWalker &walker) const {
337
337
SyntacticElementTarget result = *this ;
338
338
switch (kind) {
339
339
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)) {
342
342
result.setPattern (newPattern);
343
343
} else {
344
344
return std::nullopt;
You can’t perform that action at this time.
0 commit comments