mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Sema: fix getPublicModuleName to look only at loaded modules
When onlyIfImported is true, we should return the public module name only when the public facing module is already imported. Replace the call to getModuleByIdentifier with getLoadedModule to prevent trigering loading that module. Also fix the test where the CHECK lined ended up matching itself from the diagnostics output.
This commit is contained in:
@@ -1923,15 +1923,11 @@ ImportedModule::removeDuplicates(SmallVectorImpl<ImportedModule> &imports) {
|
||||
}
|
||||
|
||||
Identifier ModuleDecl::getPublicModuleName(bool onlyIfImported) const {
|
||||
if (!PublicModuleName.empty()) {
|
||||
if (!onlyIfImported)
|
||||
return PublicModuleName;
|
||||
if (!PublicModuleName.empty() &&
|
||||
(!onlyIfImported ||
|
||||
getASTContext().getLoadedModule(PublicModuleName)))
|
||||
return PublicModuleName;
|
||||
|
||||
bool publicModuleIsImported =
|
||||
getASTContext().getModuleByIdentifier(PublicModuleName);
|
||||
if (publicModuleIsImported)
|
||||
return PublicModuleName;
|
||||
}
|
||||
return getName();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user