@@ -6244,7 +6244,7 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
62446244 if (param->isParameterPack ())
62456245 return false ;
62466246 } else if (auto archetype = dyn_cast<ArchetypeType>(T.getPointer ())) {
6247- if (archetype-> isParameterPack ( ))
6247+ if (isa<PackArchetypeType>(archetype ))
62486248 return false ;
62496249 if (Options.PrintForSIL && isa<LocalArchetypeType>(archetype))
62506250 return false ;
@@ -6560,7 +6560,10 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
65606560
65616561 auto *typeAliasDecl = T->getDecl ();
65626562 if (typeAliasDecl->isGeneric ()) {
6563- printGenericArgs (T->getExpandedGenericArgs ());
6563+ if (Options.PrintTypesForDebugging )
6564+ printGenericArgs (T->getDirectGenericArgs ());
6565+ else
6566+ printGenericArgs (T->getExpandedGenericArgs ());
65646567 }
65656568 }
65666569
@@ -6571,7 +6574,7 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
65716574 }
65726575
65736576 void visitPackType (PackType *T) {
6574- if (Options.PrintExplicitPackTypes )
6577+ if (Options.PrintExplicitPackTypes || Options. PrintTypesForDebugging )
65756578 Printer << " Pack{" ;
65766579
65776580 auto Fields = T->getElementTypes ();
@@ -6582,7 +6585,7 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
65826585 visit (EltType);
65836586 }
65846587
6585- if (Options.PrintExplicitPackTypes )
6588+ if (Options.PrintExplicitPackTypes || Options. PrintTypesForDebugging )
65866589 Printer << " }" ;
65876590 }
65886591
@@ -6607,7 +6610,8 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
66076610
66086611 if (rootParameterPacks.empty () &&
66096612 (T->getCountType ()->isParameterPack () ||
6610- T->getCountType ()->is <PackArchetypeType>())) {
6613+ T->getCountType ()->is <PackArchetypeType>() ||
6614+ Options.PrintTypesForDebugging )) {
66116615 Printer << " /* shape: " ;
66126616 visit (T->getCountType ());
66136617 Printer << " */ " ;
@@ -6682,7 +6686,10 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
66826686 }
66836687 printQualifiedType (T);
66846688
6685- printGenericArgs (T->getExpandedGenericArgs ());
6689+ if (Options.PrintTypesForDebugging )
6690+ printGenericArgs (T->getGenericArgs ());
6691+ else
6692+ printGenericArgs (T->getExpandedGenericArgs ());
66866693 }
66876694
66886695 void visitParentType (Type T) {
@@ -7749,10 +7756,20 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
77497756 // canonical types to sugared types.
77507757 if (Options.GenericSig )
77517758 T = Options.GenericSig ->getSugaredType (T);
7759+
7760+ decl = T->getDecl ();
77527761 }
77537762
77547763 // Print opaque types as "some ..."
77557764 if (decl && decl->isOpaqueType ()) {
7765+ // For SIL, we print opaque parameter types as canonical types, and parse
7766+ // them that way too (because they're printed in this way in the SIL
7767+ // generic parameter list).
7768+ if (Options.PrintInSILBody ) {
7769+ Printer.printName (cast<GenericTypeParamType>(T->getCanonicalType ())->getName ());
7770+ return ;
7771+ }
7772+
77567773 // If we have and should print based on the type representation, do so.
77577774 if (auto opaqueRepr = decl->getOpaqueTypeRepr ()) {
77587775 if (willUseTypeReprPrinting (opaqueRepr, Type (), Options)) {
0 commit comments