[ModuleInterface] Don't print extensions to implementation-only imported types

Extensions to implementation-only types are accepted at type-checking
only if they don't define any public members. However if they declared a
conformance to a public type they were also printed in the
swiftinterface, making it unparsable because of an unknown type.

Still accept such extensions but don't print them.

rdar://problem/67516588
This commit is contained in:
Alexis Laferrière
2020-08-20 12:04:10 -07:00
parent 5c4c4dcbcf
commit fd78da5137
6 changed files with 92 additions and 0 deletions

View File

@@ -1994,6 +1994,27 @@ bool SourceFile::isImportedImplementationOnly(const ModuleDecl *module) const {
return !imports.isImportedBy(module, getParentModule());
}
bool ModuleDecl::isImportedImplementationOnly(const ModuleDecl *module) const {
auto &imports = getASTContext().getImportCache();
// Look through non-implementation-only imports to see if module is imported
// in some other way. Otherwise we assume it's implementation-only imported.
ModuleDecl::ImportFilter filter = {
ModuleDecl::ImportFilterKind::Public,
ModuleDecl::ImportFilterKind::Private,
ModuleDecl::ImportFilterKind::SPIAccessControl,
ModuleDecl::ImportFilterKind::ShadowedBySeparateOverlay};
SmallVector<ModuleDecl::ImportedModule, 4> results;
getImportedModules(results, filter);
for (auto &desc : results) {
if (imports.isImportedBy(module, desc.importedModule))
return false;
}
return true;
}
void SourceFile::lookupImportedSPIGroups(
const ModuleDecl *importedModule,
llvm::SmallSetVector<Identifier, 4> &spiGroups) const {