-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add unit test for surfacing potential regression from #5728 #5991
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
Conversation
😔 I'm not sure this warning should be triggered at all when the imports do not match exactly... Or, we should have some way to silence it in code, defaulting to parens. |
try fixture(name: "Resources/FoundationlessClient/UtilsWithFoundationPkg") { fixturePath in | ||
XCTAssertBuilds( | ||
fixturePath, | ||
Xswiftc: ["-warnings-as-errors"] |
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.
Starting a thread to discuss...
@xwu: I'm not sure this warning should be triggered at all when the imports do not match exactly... Or, we should have some way to silence it in code, defaulting to parens.
I did some researching and there is some good discussion in https://forums.swift.org/t/update-on-implementation-only-imports/26996/12 as to why the warning is triggered in the first place. What makes this tricky is that I do not think there is a way to pass a flag to silence only this warning.
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.
Understand the rationale, but this issue points to a use case where the current design doesn’t serve our needs (and, incidentally, if it were ever stabilized as an “access level” on import
like once pitched, wouldn’t behave like access modifiers do elsewhere).
I posted some thoughts over in the linked PR about why even import scanning would be brittle, and I think possibly the most resilient solution here is to come up with a new “flavor” of @_implementationOnly
(rather than a flag) that explicitly acknowledges that it can be overridden or “upgraded.”
cc @neonichu |
Thanks @ncooke3, this is a good point. We could do an import scan of modules which are using resources and adjust the generated code based on whether they import Given where we are in the 5.8 schedule, we may want to disable this change for the 5.8 tools-version and move it to |
@swift-ci smoke test |
@swift-ci smoke test macOS |
Are there any other updates needed for this PR? |
@MaxDesiatov, nothing from my end. |
@swift-ci smoke test |
@MaxDesiatov, good to merge? |
This can't be merged until it has approvals from reviewers. |
Oh right, my bad–– cc: @neonichu |
LGTM, but I wanted to run the test locally before approving since the |
Sorry for dropping the ball on this, functional tests are back enabled now, so I am just going to run the CI again here. |
@swift-ci smoke test |
No worries– the main point of this PR was to highlight/demonstrate the issue! 🙂 And that's great about the functional tests, I'll get my mixed language branch synced up so the functional tests I added can run on CI. |
@swift-ci smoke test linux |
Adds a currently failing unit test to highlight one potential regression from #5728.
I stumbled upon this when building up the test suite in #5919.
Motivation:
#5728 introduced using
@_implementationOnly
when importingFoundation.Bundle
in the generated resource bundle accessor. For Swift packages that import Foundation without@_implementationOnly
, this seems to cause the following warning:This is reproducible when using the latest 5.8 toolchain and running the unit test added in this PR.
It seems that, by using
@_implementationOnly
in the resource bundle accessor to import Foundation, it causes a warning if another swift file in the module imports Foundation without it. Ideally, the@_implementationOnly
in the resource bundle accessor should be ignored when doing this check. More info w.r.t. the warning in this bug: swiftlang/swift#56093.Modifications:
Add a unit test that is currently failing but should pass. The proper implementation fix isn't obvious to me but I wanted to open this both for reproduction and tracking purposes.
Result:
Assuming CI is using the 5.8 toolchain, it should highlight this regression.
cc: @xwu @neonichu