@@ -6445,34 +6445,45 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
6445
6445
}
6446
6446
6447
6447
void visitArraySliceType (ArraySliceType *T) {
6448
- Printer << " [" ;
6449
- visit (T->getBaseType ());
6450
- Printer << " ]" ;
6448
+ if (Options.AlwaysDesugarDictionaryTypes ) {
6449
+ visit (T->getDesugaredType ());
6450
+ } else {
6451
+ Printer << " [" ;
6452
+ visit (T->getBaseType ());
6453
+ Printer << " ]" ;
6454
+ }
6451
6455
}
6452
6456
6453
6457
void visitDictionaryType (DictionaryType *T) {
6454
- Printer << " [" ;
6455
- visit (T->getKeyType ());
6456
- Printer << " : " ;
6457
- visit (T->getValueType ());
6458
- Printer << " ]" ;
6458
+ if (Options.AlwaysDesugarDictionaryTypes ) {
6459
+ visit (T->getDesugaredType ());
6460
+ } else {
6461
+ Printer << " [" ;
6462
+ visit (T->getKeyType ());
6463
+ Printer << " : " ;
6464
+ visit (T->getValueType ());
6465
+ Printer << " ]" ;
6466
+ }
6459
6467
}
6460
6468
6461
6469
void visitOptionalType (OptionalType *T) {
6462
6470
auto printAsIUO = Options.PrintOptionalAsImplicitlyUnwrapped ;
6463
-
6464
- // Printing optionals with a trailing '!' applies only to
6465
- // top-level optionals, not to any nested within.
6466
- const_cast <PrintOptions &>(Options).PrintOptionalAsImplicitlyUnwrapped =
6467
- false ;
6468
- printWithParensIfNotSimple (T->getBaseType ());
6469
- const_cast <PrintOptions &>(Options).PrintOptionalAsImplicitlyUnwrapped =
6470
- printAsIUO;
6471
-
6472
- if (printAsIUO)
6473
- Printer << " !" ;
6474
- else
6475
- Printer << " ?" ;
6471
+ if (Options.AlwaysDesugarOptionalTypes ) {
6472
+ visit (T->getDesugaredType ());
6473
+ return ;
6474
+ } else {
6475
+ // Printing optionals with a trailing '!' applies only to
6476
+ // top-level optionals, not to any nested within.
6477
+ const_cast <PrintOptions &>(Options).PrintOptionalAsImplicitlyUnwrapped =
6478
+ false ;
6479
+ printWithParensIfNotSimple (T->getBaseType ());
6480
+ const_cast <PrintOptions &>(Options).PrintOptionalAsImplicitlyUnwrapped =
6481
+ printAsIUO;
6482
+ if (printAsIUO)
6483
+ Printer << " !" ;
6484
+ else
6485
+ Printer << " ?" ;
6486
+ }
6476
6487
}
6477
6488
6478
6489
void visitVariadicSequenceType (VariadicSequenceType *T) {
0 commit comments