mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Load modules using real names if module aliases are used
rdar://83591943
This commit is contained in:
@@ -533,7 +533,14 @@ SerializedModuleLoaderBase::findModule(ImportPath::Element moduleID,
|
||||
std::unique_ptr<llvm::MemoryBuffer> *moduleDocBuffer,
|
||||
std::unique_ptr<llvm::MemoryBuffer> *moduleSourceInfoBuffer,
|
||||
bool skipBuildingInterface, bool &isFramework, bool &isSystemModule) {
|
||||
SmallString<32> moduleName(moduleID.Item.str());
|
||||
// Find a module with an actual, physical name on disk, in case
|
||||
// -module-alias is used (otherwise same).
|
||||
//
|
||||
// For example, if '-module-alias Foo=Bar' is passed in to the frontend,
|
||||
// and a source file has 'import Foo', a module called Bar (real name)
|
||||
// should be searched.
|
||||
StringRef moduleNameRef = Ctx.getRealModuleName(moduleID.Item).str();
|
||||
SmallString<32> moduleName(moduleNameRef);
|
||||
SerializedModuleBaseName genericBaseName(moduleName);
|
||||
|
||||
auto genericModuleFileName =
|
||||
@@ -1156,7 +1163,6 @@ bool MemoryBufferSerializedModuleLoader::canImportModule(
|
||||
assert(!(mIt->second.userVersion.empty()));
|
||||
return mIt->second.userVersion >= version;
|
||||
}
|
||||
|
||||
ModuleDecl *
|
||||
SerializedModuleLoaderBase::loadModule(SourceLoc importLoc,
|
||||
ImportPath::Module path) {
|
||||
@@ -1220,13 +1226,14 @@ MemoryBufferSerializedModuleLoader::loadModule(SourceLoc importLoc,
|
||||
return nullptr;
|
||||
|
||||
auto moduleID = path[0];
|
||||
auto moduleName = Ctx.getRealModuleName(moduleID.Item).str();
|
||||
|
||||
// See if we find it in the registered memory buffers.
|
||||
|
||||
// FIXME: Right now this works only with access paths of length 1.
|
||||
// Once submodules are designed, this needs to support suffix
|
||||
// matching and a search path.
|
||||
auto bufIter = MemoryBuffers.find(moduleID.Item.str());
|
||||
auto bufIter = MemoryBuffers.find(moduleName);
|
||||
if (bufIter == MemoryBuffers.end())
|
||||
return nullptr;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user