@@ -388,8 +388,12 @@ class InheritedProtocolCollector {
388
388
// / For each type in \p directlyInherited, classify the protocols it refers to
389
389
// / as included for printing or not, and record them in the appropriate
390
390
// / vectors.
391
+ // /
392
+ // / If \p skipExtra is true then avoid recording any extra protocols to
393
+ // / print, such as synthesized conformances or conformances to non-public
394
+ // / protocols.
391
395
void recordProtocols (ArrayRef<InheritedEntry> directlyInherited,
392
- const Decl *D, bool skipSynthesized = false ) {
396
+ const Decl *D, bool skipExtra = false ) {
393
397
Optional<AvailableAttrList> availableAttrs;
394
398
395
399
for (InheritedEntry inherited : directlyInherited) {
@@ -398,6 +402,9 @@ class InheritedProtocolCollector {
398
402
continue ;
399
403
400
404
bool canPrintNormally = canPrintProtocolTypeNormally (inheritedTy, D);
405
+ if (!canPrintNormally && skipExtra)
406
+ continue ;
407
+
401
408
ExistentialLayout layout = inheritedTy->getExistentialLayout ();
402
409
for (ProtocolDecl *protoDecl : layout.getProtocols ()) {
403
410
if (canPrintNormally)
@@ -411,7 +418,7 @@ class InheritedProtocolCollector {
411
418
// any of those besides 'AnyObject'.
412
419
}
413
420
414
- if (skipSynthesized )
421
+ if (skipExtra )
415
422
return ;
416
423
417
424
// Check for synthesized protocols, like Hashable on enums.
@@ -493,11 +500,12 @@ class InheritedProtocolCollector {
493
500
if (auto *CD = dyn_cast<ClassDecl>(D)) {
494
501
for (auto *SD = CD->getSuperclassDecl (); SD;
495
502
SD = SD->getSuperclassDecl ()) {
496
- map[nominal].recordProtocols (
497
- SD-> getInherited (), SD, /* skipSynthesized =*/ true );
503
+ map[nominal].recordProtocols (SD-> getInherited (), SD,
504
+ /* skipExtra =*/ true );
498
505
for (auto *Ext: SD->getExtensions ()) {
499
506
if (shouldInclude (Ext)) {
500
- map[nominal].recordProtocols (Ext->getInherited (), Ext);
507
+ map[nominal].recordProtocols (Ext->getInherited (), Ext,
508
+ /* skipExtra=*/ true );
501
509
}
502
510
}
503
511
}
0 commit comments