@@ -50,7 +50,7 @@ struct swift::ide::api::SDKNodeInitInfo {
50
50
SDKNodeInitInfo (SDKContext &Ctx, ValueDecl *VD);
51
51
SDKNodeInitInfo (SDKContext &Ctx, OperatorDecl *D);
52
52
SDKNodeInitInfo (SDKContext &Ctx, ImportDecl *ID);
53
- SDKNodeInitInfo (SDKContext &Ctx, ProtocolConformance * Conform);
53
+ SDKNodeInitInfo (SDKContext &Ctx, ProtocolConformanceRef Conform);
54
54
SDKNodeInitInfo (SDKContext &Ctx, Type Ty, TypeInitInfo Info = TypeInitInfo());
55
55
SDKNode* createSDKNode (SDKNodeKind Kind);
56
56
};
@@ -1459,17 +1459,21 @@ SDKNodeInitInfo::SDKNodeInitInfo(SDKContext &Ctx, ImportDecl *ID):
1459
1459
Name = PrintedName = Ctx.buffer (content);
1460
1460
}
1461
1461
1462
- SDKNodeInitInfo::SDKNodeInitInfo (SDKContext &Ctx, ProtocolConformance * Conform):
1463
- SDKNodeInitInfo(Ctx, Conform-> getProtocol ()) {
1462
+ SDKNodeInitInfo::SDKNodeInitInfo (SDKContext &Ctx, ProtocolConformanceRef Conform):
1463
+ SDKNodeInitInfo(Ctx, Conform.getRequirement ()) {
1464
1464
// The conformance can be conditional. The generic signature keeps track of
1465
1465
// the requirements.
1466
- GenericSig = printGenericSignature (Ctx, Conform, Ctx.checkingABI ());
1467
- SugaredGenericSig = Ctx.checkingABI () ?
1468
- printGenericSignature (Ctx, Conform, false ): StringRef ();
1469
- // Whether this conformance is ABI placeholder depends on the decl context
1470
- // of this conformance.
1471
- IsABIPlaceholder = isABIPlaceholderRecursive (Conform->getDeclContext ()->
1472
- getAsDecl ());
1466
+ if (Conform.isConcrete ()) {
1467
+ auto *Concrete = Conform.getConcrete ();
1468
+
1469
+ GenericSig = printGenericSignature (Ctx, Concrete, Ctx.checkingABI ());
1470
+ SugaredGenericSig = Ctx.checkingABI () ?
1471
+ printGenericSignature (Ctx, Concrete, false ): StringRef ();
1472
+ // Whether this conformance is ABI placeholder depends on the decl context
1473
+ // of this conformance.
1474
+ IsABIPlaceholder = isABIPlaceholderRecursive (Concrete->getDeclContext ()->
1475
+ getAsDecl ());
1476
+ }
1473
1477
}
1474
1478
1475
1479
static bool isProtocolRequirement (ValueDecl *VD) {
@@ -1910,7 +1914,7 @@ SwiftDeclCollector::constructConformanceNode(ProtocolConformance *Conform) {
1910
1914
if (Ctx.checkingABI ())
1911
1915
Conform = Conform->getCanonicalConformance ();
1912
1916
auto ConfNode = cast<SDKNodeConformance>(SDKNodeInitInfo (Ctx,
1913
- Conform).createSDKNode (SDKNodeKind::Conformance));
1917
+ ProtocolConformanceRef ( Conform) ).createSDKNode (SDKNodeKind::Conformance));
1914
1918
Conform->forEachTypeWitness (
1915
1919
[&](AssociatedTypeDecl *assoc, Type ty, TypeDecl *typeDecl) -> bool {
1916
1920
ConfNode->addChild (constructTypeWitnessNode (assoc, ty));
@@ -1922,12 +1926,25 @@ SwiftDeclCollector::constructConformanceNode(ProtocolConformance *Conform) {
1922
1926
void swift::ide::api::
1923
1927
SwiftDeclCollector::addConformancesToTypeDecl (SDKNodeDeclType *Root,
1924
1928
NominalTypeDecl *NTD) {
1925
- // Avoid adding the same conformance twice.
1926
- SmallPtrSet<ProtocolConformance*, 4 > Seen;
1927
- for (auto &Conf: NTD->getAllConformances ()) {
1928
- if (!Ctx.shouldIgnore (Conf->getProtocol ()) && !Seen.count (Conf))
1929
- Root->addConformance (constructConformanceNode (Conf));
1930
- Seen.insert (Conf);
1929
+ if (auto *PD = dyn_cast<ProtocolDecl>(NTD)) {
1930
+ PD->walkInheritedProtocols ([&](ProtocolDecl *inherited) {
1931
+ if (PD != inherited && !Ctx.shouldIgnore (inherited)) {
1932
+ ProtocolConformanceRef Conf (inherited);
1933
+ auto ConfNode = SDKNodeInitInfo (Ctx, Conf)
1934
+ .createSDKNode (SDKNodeKind::Conformance);
1935
+ Root->addConformance (ConfNode);
1936
+ }
1937
+
1938
+ return TypeWalker::Action::Continue;
1939
+ });
1940
+ } else {
1941
+ // Avoid adding the same conformance twice.
1942
+ SmallPtrSet<ProtocolConformance*, 4 > Seen;
1943
+ for (auto &Conf: NTD->getAllConformances ()) {
1944
+ if (!Ctx.shouldIgnore (Conf->getProtocol ()) && !Seen.count (Conf))
1945
+ Root->addConformance (constructConformanceNode (Conf));
1946
+ Seen.insert (Conf);
1947
+ }
1931
1948
}
1932
1949
}
1933
1950
0 commit comments