mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Merge pull request #60659 from xymus/print-missing-imports
[ModuleInterface] Print missing imports in swiftinterface
This commit is contained in:
@@ -1570,6 +1570,11 @@ void ModuleDecl::getImportedModules(SmallVectorImpl<ImportedModule> &modules,
|
||||
FORWARD(getImportedModules, (modules, filter));
|
||||
}
|
||||
|
||||
void ModuleDecl::getMissingImportedModules(
|
||||
SmallVectorImpl<ImportedModule> &imports) const {
|
||||
FORWARD(getMissingImportedModules, (imports));
|
||||
}
|
||||
|
||||
void
|
||||
SourceFile::getImportedModules(SmallVectorImpl<ImportedModule> &modules,
|
||||
ModuleDecl::ImportFilter filter) const {
|
||||
@@ -1604,6 +1609,12 @@ SourceFile::getImportedModules(SmallVectorImpl<ImportedModule> &modules,
|
||||
}
|
||||
}
|
||||
|
||||
void SourceFile::getMissingImportedModules(
|
||||
SmallVectorImpl<ImportedModule> &modules) const {
|
||||
for (auto module : MissingImportedModules)
|
||||
modules.push_back(module);
|
||||
}
|
||||
|
||||
void SourceFile::dumpSeparatelyImportedOverlays() const {
|
||||
for (auto &pair : separatelyImportedOverlays) {
|
||||
auto &underlying = std::get<0>(pair);
|
||||
@@ -2535,6 +2546,21 @@ RestrictedImportKind SourceFile::getRestrictedImportKind(const ModuleDecl *modul
|
||||
if (imports.isImportedBy(module, getParentModule()))
|
||||
return RestrictedImportKind::None;
|
||||
|
||||
if (importKind == RestrictedImportKind::Implicit &&
|
||||
(module->getLibraryLevel() == LibraryLevel::API ||
|
||||
getParentModule()->getLibraryLevel() != LibraryLevel::API)) {
|
||||
// Hack to fix swiftinterfaces in case of missing imports.
|
||||
// We can get rid of this logic when we don't leak the use of non-locally
|
||||
// imported things in API.
|
||||
ImportPath::Element pathElement = {module->getName(), SourceLoc()};
|
||||
auto pathArray = getASTContext().AllocateCopy(
|
||||
llvm::makeArrayRef(pathElement));
|
||||
auto missingImport = ImportedModule(
|
||||
ImportPath::Access(pathArray),
|
||||
const_cast<ModuleDecl *>(module));
|
||||
addMissingImportedModule(missingImport);
|
||||
}
|
||||
|
||||
return importKind;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user