Skip to content

Commit eb77da1

Browse files
committed
SymbolGraph: Stop calling getAllConformances() on protocols
1 parent 701f782 commit eb77da1

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

lib/SymbolGraphGen/SymbolGraph.cpp

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -448,11 +448,24 @@ void
448448
SymbolGraph::recordConformanceRelationships(Symbol S) {
449449
const auto VD = S.getSymbolDecl();
450450
if (const auto *NTD = dyn_cast<NominalTypeDecl>(VD)) {
451-
for (const auto *Conformance : NTD->getAllConformances()) {
452-
recordEdge(Symbol(this, VD, nullptr),
453-
Symbol(this, Conformance->getProtocol(), nullptr),
454-
RelationshipKind::ConformsTo(),
455-
dyn_cast_or_null<ExtensionDecl>(Conformance->getDeclContext()));
451+
if (auto *PD = dyn_cast<ProtocolDecl>(NTD)) {
452+
PD->walkInheritedProtocols([&](ProtocolDecl *inherited) {
453+
if (inherited != PD) {
454+
recordEdge(Symbol(this, VD, nullptr),
455+
Symbol(this, inherited, nullptr),
456+
RelationshipKind::ConformsTo(),
457+
nullptr);
458+
}
459+
460+
return TypeWalker::Action::Continue;
461+
});
462+
} else {
463+
for (const auto *Conformance : NTD->getAllConformances()) {
464+
recordEdge(Symbol(this, VD, nullptr),
465+
Symbol(this, Conformance->getProtocol(), nullptr),
466+
RelationshipKind::ConformsTo(),
467+
dyn_cast_or_null<ExtensionDecl>(Conformance->getDeclContext()));
468+
}
456469
}
457470
}
458471
}

0 commit comments

Comments
 (0)