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 #78634

Merged
merged 1 commit into from
Jan 15, 2025

Conversation

egorzhdan
Copy link
Contributor

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

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
@egorzhdan egorzhdan added the c++ interop Feature: Interoperability with C++ label Jan 14, 2025
@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test

Copy link
Contributor

@Xazax-hun Xazax-hun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The patch looks good to me. Do we have a ticket tracking the more general issue of collisions between namespaces and modules?

@egorzhdan
Copy link
Contributor Author

Yeah, this is a pure-Swift issue, #43510 – there isn't always a way to distinguish a Swift module from a Swift type when referring to them by name.

@egorzhdan egorzhdan merged commit dd11207 into main Jan 15, 2025
3 checks passed
@egorzhdan egorzhdan deleted the egorzhdan/os-logger branch January 15, 2025 13:11
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