mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[IDE] Avoid printing some Swift extensions twice in mixed source frameworks
`printModuleInterfaceDecl` printes extensions right after the type they are associated with is printed. Extensions associated with a type that appears in the "target" module shouldn't be added to `SwiftDecls` because that would lead to double printing them.
This commit is contained in:
@@ -145,17 +145,6 @@ static bool printModuleInterfaceDecl(Decl *D,
|
||||
Printer.callAvoidPrintDeclPost(D);
|
||||
return false;
|
||||
}
|
||||
if (auto Ext = dyn_cast<ExtensionDecl>(D)) {
|
||||
// Clang extensions (categories) are always printed in source order.
|
||||
// Swift extensions are printed with their associated type unless it's
|
||||
// a cross-module extension.
|
||||
if (!extensionHasClangNode(Ext)) {
|
||||
auto ExtendedNominal = Ext->getExtendedNominal();
|
||||
if (!ExtendedNominal ||
|
||||
Ext->getModuleContext() == ExtendedNominal->getModuleContext())
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// It'd be nice to avoid cloning the options here, but that would require
|
||||
// SynthesizedExtensionAnalyzer to promise to stay within the lifetime of
|
||||
@@ -677,6 +666,14 @@ void swift::ide::printModuleInterface(
|
||||
addToClangDecls(Ext, extensionGetClangNode(Ext));
|
||||
continue;
|
||||
}
|
||||
|
||||
// Swift extensions are printed with their associated type unless it's
|
||||
// a cross-module extension.
|
||||
if (auto extendedTy = Ext->getExtendedNominal()) {
|
||||
if (TargetMod->isSameModuleLookingThroughOverlays(
|
||||
extendedTy->getModuleContext()))
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!IsSubmodule) {
|
||||
|
||||
Reference in New Issue
Block a user