Skip to content

Sema: ignore inconsistent imports from a file generated by Xcode #71559

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion lib/Sema/ImportResolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
13 changes: 13 additions & 0 deletions test/Sema/access-level-import-inconsistencies.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,16 @@ package import Lib // expected-note {{imported 'package' here}} @:1
import Lib
//--- ManyFiles_AmbiguitySwift6_FileB.swift
internal import Lib

/// Don't report inconsistencies from a file generated by Xcode.
// RUN: %target-swift-frontend -typecheck -I %t \
// RUN -primary-file %t/GeneratedAssetSymbols.swift \
// RUN: %t/UserWrittenFile.swift -verify
// RUN: %target-swift-frontend -typecheck -I %t \
// RUN %t/GeneratedAssetSymbols.swift \
// RUN: -primary-file %t/UserWrittenFile.swift -verify
//--- UserWrittenFile.swift
internal import Lib
//--- GeneratedAssetSymbols.swift
import Lib