mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
* Revert "Revert "[SymbolGraphGen] synthesize child symbols for type aliases of private…" (#79062)"
This reverts commit cac82978bc.
* clean up use of DenseMap in SymbolGraphGen
rdar://143865173
This commit is contained in:
@@ -181,6 +181,9 @@ static bool isUnavailableOrObsoletedOnPlatform(const Decl *D) {
|
||||
}
|
||||
|
||||
bool SymbolGraphASTWalker::walkToDeclPre(Decl *D, CharSourceRange Range) {
|
||||
if (SynthesizedChildrenBaseDecl && D == SynthesizedChildrenBaseDecl)
|
||||
return true;
|
||||
|
||||
if (isUnavailableOrObsoletedOnPlatform(D)) {
|
||||
return false;
|
||||
}
|
||||
@@ -301,7 +304,7 @@ bool SymbolGraphASTWalker::walkToDeclPre(Decl *D, CharSourceRange Range) {
|
||||
|
||||
auto *VD = cast<ValueDecl>(D);
|
||||
|
||||
if (!SG->canIncludeDeclAsNode(VD)) {
|
||||
if (!BaseDecl && !SG->canIncludeDeclAsNode(VD)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -332,8 +335,21 @@ bool SymbolGraphASTWalker::walkToDeclPre(Decl *D, CharSourceRange Range) {
|
||||
}
|
||||
}
|
||||
|
||||
if (const auto *TD = dyn_cast_or_null<TypeAliasDecl>(VD)) {
|
||||
const auto InnerType = TD->getUnderlyingType();
|
||||
if (NominalTypeDecl *NTD = InnerType->getAnyNominal()) {
|
||||
// Only fold typedefs together if the inner type is from our module and it
|
||||
// otherwise isn't being shown
|
||||
if (isOurModule(NTD->getModuleContext()) &&
|
||||
!SG->canIncludeDeclAsNode(NTD)) {
|
||||
PublicPrivateTypeAliases.insert_or_assign(NTD, TD);
|
||||
synthesizeChildSymbols(NTD, TD);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Otherwise, record this in the main module `M`'s symbol graph.
|
||||
SG->recordNode(Symbol(SG, VD, nullptr));
|
||||
SG->recordNode(Symbol(SG, VD, BaseDecl));
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -402,3 +418,15 @@ bool SymbolGraphASTWalker::shouldBeRecordedAsExtension(
|
||||
!isExportedImportedModule(
|
||||
ED->getExtendedNominal()->getModuleContext());
|
||||
}
|
||||
|
||||
bool SymbolGraphASTWalker::synthesizeChildSymbols(Decl *D,
|
||||
const ValueDecl *BD) {
|
||||
BaseDecl = BD;
|
||||
SynthesizedChildrenBaseDecl = D;
|
||||
SWIFT_DEFER {
|
||||
BaseDecl = nullptr;
|
||||
SynthesizedChildrenBaseDecl = nullptr;
|
||||
};
|
||||
|
||||
return walk(D);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user