mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Sema: ignore inconsistent bare imports from a file generated by Xcode
In Swift 5 mode, the compiler reports when two files import the same module, where one file has a bare import and the other an access-level import. This avoids unintentionally promoting the import to public when preexisting code marked it otherwise. Exempt a file generated by Xcode from this check as it's not user modifiable. In the future, we should identify such generated files properly. Either with a new attribute or in the way they are passed to the compiler. rdar://122032472
This commit is contained in:
@@ -1055,8 +1055,15 @@ CheckInconsistentAccessLevelOnImport::evaluate(
|
||||
auto mod = SF->getParentModule();
|
||||
auto diagnose = [mod](const ImportDecl *implicitImport,
|
||||
const ImportDecl *otherImport) {
|
||||
auto otherAccessLevel = otherImport->getAccessLevel();
|
||||
// Ignore files generated by Xcode. We should probably identify them via
|
||||
// an attribuite or frontend flag, until them match the file by name.
|
||||
SourceFile *implicitSF =
|
||||
implicitImport->getDeclContext()->getParentSourceFile();
|
||||
StringRef basename = llvm::sys::path::filename(implicitSF->getFilename());
|
||||
if (basename == "GeneratedAssetSymbols.swift")
|
||||
return;
|
||||
|
||||
auto otherAccessLevel = otherImport->getAccessLevel();
|
||||
auto &diags = mod->getDiags();
|
||||
{
|
||||
InFlightDiagnostic error =
|
||||
|
||||
Reference in New Issue
Block a user