Skip to content

Commit e1d35d9

Browse files
committed
[AST] Introduce TypedPattern::createPropagated
1 parent f9879b1 commit e1d35d9

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

include/swift/AST/Pattern.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,13 @@ class TypedPattern : public Pattern {
447447
return tp;
448448
}
449449

450+
static TypedPattern *createPropagated(ASTContext &ctx, Pattern *pattern,
451+
TypeRepr *typeRepr) {
452+
auto *TP = new (ctx) TypedPattern(pattern, typeRepr);
453+
TP->setPropagatedType();
454+
return TP;
455+
}
456+
450457
/// True if the type in this \c TypedPattern was propagated from a different
451458
/// \c TypedPattern.
452459
///

lib/Parse/ParseDecl.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8536,9 +8536,8 @@ Parser::parseDeclVar(ParseDeclOptions Flags,
85368536
Status.setIsParseError();
85378537
}
85388538

8539-
TypedPattern *NewTP = new (Context) TypedPattern(PrevPat,
8540-
TP->getTypeRepr());
8541-
NewTP->setPropagatedType();
8539+
auto *NewTP = TypedPattern::createPropagated(Context, PrevPat,
8540+
TP->getTypeRepr());
85428541
PBDEntries[i-1].setPattern(NewTP);
85438542
}
85448543
}

0 commit comments

Comments
 (0)