Emit module selectors in swiftinterfaces

This support is currently opt-in and can be disabled by a blocklist.
This commit is contained in:
Becca Royal-Gordon
2025-10-17 19:05:53 -07:00
parent 89ecc5ab2a
commit 9454c0aaa4
10 changed files with 245 additions and 16 deletions

View File

@@ -884,13 +884,22 @@ bool swift::emitSwiftInterface(raw_ostream &out,
printImports(out, Opts, M, aliasModuleNamesTargets);
bool useExportedModuleNames = Opts.printPublicInterface();
// Apply module selector blocklist.
bool useModuleSelectors = Opts.UseModuleSelectors;
if (useModuleSelectors && M->getASTContext().blockListConfig
.hasBlockListAction(M->getNameStr(), BlockListKeyKind::ModuleName,
BlockListAction::
DisableModuleSelectorsInModuleInterface))
useModuleSelectors = false;
bool useExportedModuleNames = Opts.printPublicInterface();
const PrintOptions printOptions = PrintOptions::printSwiftInterfaceFile(
M, Opts.PreserveTypesAsWritten, Opts.PrintFullConvention,
M, useModuleSelectors, Opts.PreserveTypesAsWritten,
Opts.PrintFullConvention,
Opts.InterfaceContentMode,
useExportedModuleNames,
Opts.AliasModuleNames, &aliasModuleNamesTargets);
InheritedProtocolCollector::PerTypeMap inheritedProtocolMap;
SmallVector<Decl *, 16> topLevelDecls;
@@ -909,7 +918,8 @@ bool swift::emitSwiftInterface(raw_ostream &out,
D->print(out, printOptions);
out << "\n";
diagnoseIfDeclShadowsKnownModule(Opts, const_cast<Decl *>(D), M);
if (!useModuleSelectors)
diagnoseIfDeclShadowsKnownModule(Opts, const_cast<Decl *>(D), M);
}
// Print dummy extensions for any protocols that were indirectly conformed to.