Skip to content

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

iCharlesHu
Copy link
Contributor

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 the Foundation module and some other module A will always prefer module A's declaration.

See #58625 and #34642

@iCharlesHu iCharlesHu requested a review from parkera October 19, 2022 23:30
@iCharlesHu
Copy link
Contributor Author

@swift-ci please test

1 similar comment
@iCharlesHu
Copy link
Contributor Author

@swift-ci please test

Copy link
Member

@kavon kavon left a 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.

@iCharlesHu
Copy link
Contributor Author

@swift-ci Please Build Toolchain macOS Platform

@iCharlesHu
Copy link
Contributor Author

@swift-ci please test


// REQUIRES: objc_interop

import Foundation
Copy link
Member

@kavon kavon Jan 3, 2023

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.

@kavon
Copy link
Member

kavon commented Jan 4, 2023

@swift-ci Please Build Toolchain macOS Platform

1 similar comment
@iCharlesHu
Copy link
Contributor Author

@swift-ci Please Build Toolchain macOS Platform

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants