[Explicit Moduele Builds] Look through forwarding modules for 'canImport' version check.

Otherwise we default to version 0 for all modules which get forwarded.

Resolves rdar://119346213
This commit is contained in:
Artem Chikin
2023-12-08 15:15:41 -08:00
parent f5e2b24912
commit 22d39e91e7
2 changed files with 54 additions and 0 deletions

View File

@@ -2246,6 +2246,21 @@ bool ExplicitSwiftModuleLoader::canImportModule(
it->second.modulePath);
return false;
}
// If it's a forwarding module, load the YAML file from disk and get the path
// to the actual module for the version check.
if (!serialization::isSerializedAST((*moduleBuf)->getBuffer())) {
if (auto forwardingModule = ForwardingModule::load(**moduleBuf)) {
moduleBuf = fs.getBufferForFile(forwardingModule->underlyingModulePath);
if (!moduleBuf) {
Ctx.Diags.diagnose(SourceLoc(),
diag::error_opening_explicit_module_file,
forwardingModule->underlyingModulePath);
return false;
}
}
}
auto metaData = serialization::validateSerializedAST(
(*moduleBuf)->getBuffer(), Ctx.SILOpts.EnableOSSAModules,
Ctx.LangOpts.SDKName, !Ctx.LangOpts.DebuggerSupport);