File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -285,6 +285,9 @@ struct PrintOptions {
285
285
286
286
bool PrintImplicitAttrs = true ;
287
287
288
+ // / Whether to print the \c each keyword for pack archetypes.
289
+ bool PrintExplicitEach = false ;
290
+
288
291
// / Whether to print the \c any keyword for existential
289
292
// / types.
290
293
bool PrintExplicitAny = false ;
Original file line number Diff line number Diff line change @@ -5416,6 +5416,8 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
5416
5416
} else if (auto existential = dyn_cast<ExistentialMetatypeType>(T.getPointer ())) {
5417
5417
if (!Options.PrintExplicitAny )
5418
5418
return isSimpleUnderPrintOptions (existential->getInstanceType ());
5419
+ } else if (isa<PackArchetypeType>(T.getPointer ())) {
5420
+ return !Options.PrintExplicitEach ;
5419
5421
}
5420
5422
return T->hasSimpleTypeRepr ();
5421
5423
}
@@ -5731,8 +5733,11 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
5731
5733
}
5732
5734
5733
5735
void visitPackExpansionType (PackExpansionType *T) {
5734
- visit (T->getPatternType ());
5735
- Printer << " ..." ;
5736
+ PrintOptions innerOptions = Options;
5737
+ innerOptions.PrintExplicitEach = true ;
5738
+
5739
+ Printer << " repeat " ;
5740
+ TypePrinter (Printer, innerOptions).visit (T->getPatternType ());
5736
5741
}
5737
5742
5738
5743
void visitTupleType (TupleType *T) {
@@ -6679,6 +6684,8 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
6679
6684
}
6680
6685
6681
6686
void visitPackArchetypeType (PackArchetypeType *T) {
6687
+ if (Options.PrintExplicitEach )
6688
+ Printer << " each " ;
6682
6689
printArchetypeCommon (T);
6683
6690
}
6684
6691
You can’t perform that action at this time.
0 commit comments