Tweak diagnostic message when importing the current module.

Before:
  error: cannot import module being compiled
After:
  warning: file 'foo.swift' is part of module 'Foo'; ignoring import

rdar://problem/22635888

Swift SVN r31995
This commit is contained in:
Jordan Rose
2015-09-16 17:24:13 +00:00
parent e1e439da1e
commit a42531ebf0
4 changed files with 26 additions and 5 deletions

View File

@@ -150,8 +150,15 @@ void NameBinder::addImport(
if (ID->getModulePath().front().first == SF.getParentModule()->getName() &&
ID->getModulePath().size() == 1 && !shouldImportSelfImportClang(ID, SF)) {
// If the imported module name is the same as the current module,
// produce an error.
Context.Diags.diagnose(ID, diag::sema_import_current_module);
// produce a diagnostic.
StringRef filename = llvm::sys::path::filename(SF.getFilename());
if (filename.empty())
Context.Diags.diagnose(ID, diag::sema_import_current_module,
ID->getModulePath().front().first);
else
Context.Diags.diagnose(ID, diag::sema_import_current_module_with_file,
filename, ID->getModulePath().front().first);
ID->setModule(SF.getParentModule());
return;
}