@@ -2064,7 +2064,21 @@ namespace {
20642064 printCommonPost (PD);
20652065 }
20662066
2067- void printGenericParameters (GenericParamList *Params) {
2067+ void printGenericSignature (const GenericSignature &Sig, Label label) {
2068+ if (!Sig)
2069+ return ;
2070+
2071+ printRecArbitrary ([&](Label label) {
2072+ printHead (" generic_signature" , ASTNodeColor, label);
2073+ printList (Sig.getGenericParams (), [&](auto GP, Label label) {
2074+ printTypeField (GP, label);
2075+ }, Label::always (" generic_params" ));
2076+ printGenericRequirements (Sig.getRequirements ());
2077+ printFoot ();
2078+ }, label);
2079+ }
2080+
2081+ void printParsedGenericParams (GenericParamList *Params) {
20682082 if (!Params)
20692083 return ;
20702084
@@ -2101,20 +2115,13 @@ namespace {
21012115 printCommon ((Decl*)VD, Name, label, Color);
21022116
21032117 printDeclName (VD, Label::optional (" name" ));
2104- if (auto *AFD = dyn_cast<AbstractFunctionDecl>(VD)) {
2105- printGenericParameters (AFD->getParsedGenericParams ());
2106- if (AFD->hasComputedGenericSignature ())
2107- printGenericRequirements (AFD->getGenericRequirements ());
2108- }
2109- if (auto *GTD = dyn_cast<GenericTypeDecl>(VD)) {
2110- printGenericParameters (GTD->getParsedGenericParams ());
2111- if (GTD->hasComputedGenericSignature ())
2112- printGenericRequirements (GTD->getGenericRequirements ());
2113- }
2114- if (auto *MD = dyn_cast<MacroDecl>(VD)) {
2115- printGenericParameters (MD->getParsedGenericParams ());
2116- if (MD->hasComputedGenericSignature ())
2117- printGenericRequirements (MD->getGenericRequirements ());
2118+ if (auto *GC = VD->getAsGenericContext ()) {
2119+ if (Writer.isParsable () && GC->hasComputedGenericSignature ()) {
2120+ printGenericSignature (GC->getGenericSignature (),
2121+ Label::optional (" generic_signature" ));
2122+ } else {
2123+ printParsedGenericParams (GC->getParsedGenericParams ());
2124+ }
21182125 }
21192126
21202127 if (VD->hasInterfaceType ()) {
@@ -2277,11 +2284,7 @@ namespace {
22772284 }
22782285
22792286 void printStorageImpl (AbstractStorageDecl *D) {
2280- // Use a different label for the parsable outputs because "type: true" is
2281- // confusing, especially when we also have keys elsewhere named "type"
2282- // that are type USRs.
2283- printFlag (D->isStatic (), Writer.isParsable () ? " static" : " type" ,
2284- DeclModifierColor);
2287+ printFlag (D->isStatic (), " static" , DeclModifierColor);
22852288
22862289 if (D->hasInterfaceType ()) {
22872290 auto impl = D->getImplInfo ();
@@ -2519,10 +2522,7 @@ namespace {
25192522
25202523 void printCommonFD (FuncDecl *FD, const char *type, Label label) {
25212524 printCommonAFD (FD, type, label);
2522- // Use a different label for the parsable outputs because "type: true" is
2523- // confusing, especially when we also have keys elsewhere named "type"
2524- // that are type USRs.
2525- printFlag (FD->isStatic (), Writer.isParsable () ? " static" : " type" );
2525+ printFlag (FD->isStatic (), " static" , DeclModifierColor);
25262526 }
25272527
25282528 void visitFuncDecl (FuncDecl *FD, Label label) {
@@ -5316,14 +5316,15 @@ class PrintConformance : public PrintBase {
53165316 // parsable (JSON) output because it is far too much information when it is
53175317 // rendered as part of every declref that contains such a conformance.
53185318 auto shouldPrintDetails =
5319- visited.insert (conformance).second ; // && !Writer.isParsable();
5319+ visited.insert (conformance).second && !Writer.isParsable ();
53205320
53215321 auto printCommon = [&](StringRef kind) {
53225322 printHead (kind, ASTNodeColor, label);
53235323 printTypeField (conformance->getType (), Label::always (" type" ));
53245324 printReferencedDeclField (conformance->getProtocol (),
53255325 Label::always (" protocol" ));
5326- printFlag (!shouldPrintDetails, " <details printed above>" );
5326+ if (!Writer.isParsable ())
5327+ printFlag (!shouldPrintDetails, " <details printed above>" );
53275328 };
53285329
53295330 switch (conformance->getKind ()) {
0 commit comments