Re-apply "[serialization] Reject loading a module with the wrong case."

This included a test that failed on case-sensitive filesystems. Test fixed.

(Aside: Why not just have this fail with "no such module"? Why use a different
error? Because even if "import FOO" picks up a module named 'Foo', there may
actually be a module named 'FOO' on the system (in another folder), and we
should be able to find that. Fixing that is tracked by rdar://problem/18691936.)

rdar://problem/15632996 (again)

Swift SVN r22856
This commit is contained in:
Jordan Rose
2014-10-21 00:30:09 +00:00
parent c3a4ae056c
commit 9d9f9ef150
8 changed files with 46 additions and 7 deletions

View File

@@ -191,6 +191,7 @@ FileUnit *SerializedModuleLoader::loadAST(
return nullptr;
case ModuleStatus::MissingDependency:
case ModuleStatus::MissingShadowedModule:
case ModuleStatus::NameMismatch:
llvm_unreachable("dependencies haven't been loaded yet");
}
@@ -207,12 +208,24 @@ FileUnit *SerializedModuleLoader::loadAST(
// We failed to bring the module file into the AST.
M.removeFile(*fileUnit);
assert(loadedModuleFile->getStatus() == ModuleStatus::MissingDependency ||
assert(loadedModuleFile->getStatus() == ModuleStatus::NameMismatch ||
loadedModuleFile->getStatus() == ModuleStatus::MissingDependency ||
loadedModuleFile->getStatus() == ModuleStatus::MissingShadowedModule);
if (!diagLoc)
return nullptr;
if (loadedModuleFile->getStatus() == ModuleStatus::NameMismatch) {
// FIXME: This doesn't handle a non-debugger REPL, which should also treat
// this as a non-fatal error.
auto diagKind = diag::serialization_name_mismatch;
if (Ctx.LangOpts.DebuggerSupport)
diagKind = diag::serialization_name_mismatch_repl;
Ctx.Diags.diagnose(*diagLoc, diagKind,
loadedModuleFile->getModuleName(), M.Name);
return nullptr;
}
if (loadedModuleFile->getStatus() == ModuleStatus::MissingShadowedModule) {
Ctx.Diags.diagnose(*diagLoc, diag::serialization_missing_shadowed_module,
M.Name);