Skip to content

Disable implementationOnly Foundation import for resource accessor #5997

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
Jan 17, 2023

Conversation

neonichu
Copy link
Contributor

This was a change that landed in #5728 but it has the unintended consequence of generating unfixable warnings for packages which do import Foundation. We can probably solve that with import scanning to decide between the two import types, but given where we are in the 5.8 schedule, this seems to be something better done for a future manifest version.

See also #5991

@neonichu neonichu requested a review from abertelrud as a code owner December 22, 2022 19:17
@neonichu neonichu self-assigned this Dec 22, 2022
@neonichu neonichu requested review from tomerd and elsh as code owners December 22, 2022 19:17
@neonichu
Copy link
Contributor Author

@swift-ci please smoke test

@neonichu
Copy link
Contributor Author

If we decide to merge this, we'll also need a 5.8 cherry-pick, of course.

@MaxDesiatov
Copy link
Contributor

We can probably solve that with import scanning to decide between the two import types

Can you elaborate on this? How exactly would this work?

@neonichu
Copy link
Contributor Author

Can you elaborate on this? How exactly would this work?

I was thinking we do an import scan on all files of any modules that contains resources and if we find imports of Foundation, we would generate code with a regular import instead of the implementation-only one.

@MaxDesiatov
Copy link
Contributor

Is there some specific tooling already for this type of scanning, or do you think that a simple textual search without even parsing source files would be sufficient?

@neonichu
Copy link
Contributor Author

Is there some specific tooling already for this type of scanning, or do you think that a simple textual search without even parsing source files would be sufficient?

Yah, we have SwiftcImportScanner which does this by shelling out to the compiler.

@xwu
Copy link
Contributor

xwu commented Dec 24, 2022

Yah, we have SwiftcImportScanner which does this by shelling out to the compiler.

We may need to augment the compiler so as to distinguish @_implementationOnly imports from regular ones; otherwise, we would be reproducing the same problem but flipping the polarity (in other words, emitting a non-@_implementationOnly import that causes an unsilenceable warning for packages that only import Foundation as an implementation-only package).

Also (just a brain dump here) this will need to be kept in sync with future Foundation modularization—a user may down the line import one of the future packages like FoundationEssentials and the invocation of the scanner here will need to know what Bundle is a part of.

One alternative which I anticipate will be less high-maintenance would be an augmentation of @_implementationOnly spelled something like @_implementationOnly(overridable) which tells the compiler that this “access level” (recall Jordan once pitched this as an “internal” import) can be superseded.

@neonichu
Copy link
Contributor Author

otherwise, we would be reproducing the same problem but flipping the polarity

That is true, but also a pre-existing problem that as far as I know hasn't been reported so far. Because of that, I think it would be ok to ignore for now.

I think for 5.8, the most sensible thing is to go back to the 5.7 behavior and revisit for 5.9+ in some other form. Other thoughts?

@xwu
Copy link
Contributor

xwu commented Jan 16, 2023

Agree, probably best to roll back for now.

This was a change that landed in #5728 but it has the unintended consequence of generating unfixable warnings for packages which do import Foundation. We can probably solve that with import scanning to decide between the two import types, but given where we are in the 5.8 schedule, this seems to be something better done for a future manifest version.
@neonichu neonichu force-pushed the disable-implicit-foundation branch from b20845f to 44f19ff Compare January 17, 2023 09:32
@neonichu
Copy link
Contributor Author

@swift-ci please smoke test

@neonichu neonichu merged commit cb9d03b into main Jan 17, 2023
@neonichu neonichu deleted the disable-implicit-foundation branch January 17, 2023 16:50
neonichu added a commit that referenced this pull request Jan 17, 2023
…5997)

This was a change that landed in #5728 but it has the unintended consequence of generating unfixable warnings for packages which do import Foundation. We can probably solve that with import scanning to decide between the two import types, but given where we are in the 5.8 schedule, this seems to be something better done for a future manifest version.

(cherry picked from commit cb9d03b)
neonichu added a commit that referenced this pull request Jan 23, 2023
…5997) (#6055)

This was a change that landed in #5728 but it has the unintended consequence of generating unfixable warnings for packages which do import Foundation. We can probably solve that with import scanning to decide between the two import types, but given where we are in the 5.8 schedule, this seems to be something better done for a future manifest version.

(cherry picked from commit cb9d03b)
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.

4 participants