-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Allow code to shadow definitions in the Foundation module #61642
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
base: main
Are you sure you want to change the base?
Conversation
@swift-ci please test |
1 similar comment
@swift-ci please test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the motivation for this change? If there was a clearer picture of the need behind this, perhaps a different solution would be better.
At first brush, I do not think elevating Foundation to have this special status makes sense, because it has to be explicitly imported, so you already have to opt-in to having its declarations in scope. The standard library is always implicitly imported, so we need the shadowing behavior to not disrupt declarations from explicit imports, etc.
@swift-ci Please Build Toolchain macOS Platform |
0778b02
to
4fa8296
Compare
@swift-ci please test |
|
||
// REQUIRES: objc_interop | ||
|
||
import Foundation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not quite sure what the changes in this Constraints
test does for us, especially now that the shadowing change is behind a feature flag.
I think any test changes other than for the new foundation-module-shadowing.swift
should be reverted so they cover what they did previously.
@swift-ci Please Build Toolchain macOS Platform |
1 similar comment
@swift-ci Please Build Toolchain macOS Platform |
This PR implements the same type of shadowing rule to the
Foundation
module that applies to the Swift standard library: unqualified references to declarations imported from both theFoundation
module and some other moduleA
will always prefer moduleA
's declaration.See #58625 and #34642