Skip to content
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

🍒[cxx-interop] Workaround name lookup issues with namespace os #78656

Open
wants to merge 2 commits into
base: release/6.1
Choose a base branch
from

Conversation

egorzhdan
Copy link
Contributor

@egorzhdan egorzhdan commented Jan 15, 2025

Explanation: On Apple platforms, a system module os declares a namespace os under #if defined(__cplusplus). This causes ClangImporter to import it as enum os when C++ interop is enabled. This causes name lookup ambiguity (module os vs namespace os) which is resolved in namespace's favor, breaking existing usages.
Scope: This changes ClangImporter to not import a particular C++ namespace into Swift.
Risk: Low, this only affects the import of C++ namespace named os in a module named os.
Testing: Added a new compiler test.
Issue: rdar://119044493
Reviewer: @Xazax-hun

Original PR: #78634

On Apple platforms, a system module `os` declares a `namespace os` under `#if defined(__cplusplus)`. This causes ClangImporter to import it as `enum os` when C++ interop is enabled. This causes name lookup ambiguity (module os vs namespace os) which is resolved in namespace's favor, breaking existing usages.

rdar://119044493
(cherry picked from commit 430809d)
@egorzhdan egorzhdan added the c++ interop Feature: Interoperability with C++ label Jan 15, 2025
@egorzhdan
Copy link
Contributor Author

@swift-ci please test

@egorzhdan egorzhdan marked this pull request as ready for review January 15, 2025 15:39
@egorzhdan egorzhdan requested a review from a team as a code owner January 15, 2025 15:39
The API that is being used is not available on all versions of all platforms.

rdar://142973844
@egorzhdan
Copy link
Contributor Author

@swift-ci please test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ interop Feature: Interoperability with C++
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants