-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Sema: Opt-in check for structs references to hidden dependencies in non-library-evolution mode #85179
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
xymus
wants to merge
5
commits into
swiftlang:main
Choose a base branch
from
xymus:exportability-nle-structs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+295
−15
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
@swift-ci Please smoke test |
1 similar comment
|
@swift-ci Please smoke test |
|
@swift-ci Please smoke test macOS |
|
🎉 |
Gate it behind CheckImplementationOnly.
…onOnly In non-library-evolution mode, gated behind the CheckImplementationOnly feature flag, consider structs to be a fragile use site by default, unless marked `@_implementationOnly`. This prevents them to refer to restricted imports like implementation-only.
In non-library-evolution mode, gated behind the CheckImplementationOnly feature flag, report references to structs marked with `@_implementationOnly` from a fragile context. Preventing references from inlinable functions and structs not marked `@_implementationOnly`.
…youts Don't consider implicitly exposed memory layouts when checking for usable from inline correctness. That check applies only to memory layouts marked as exposed explicitly. Consider the implict state only at the general availability checking.
e9d809d to
bf44341
Compare
|
@swift-ci Please smoke test |
|
@swift-ci Please smoke test Windows |
1 similar comment
|
@swift-ci Please smoke test Windows |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
While
@_implementationOnly(and family) is properly type-checking in library-evolution mode we did not have an equivalent in non-library-evolution mode. In this case more internal details are exposed to the client, so the library-evolution checks aren’t sufficient. This PR aims at bridging that gap and take a step in the right direction to properly support@_implementationOnlyimports and more widely hiding dependencies in non-library-evolution mode.This PR introduces an opt-in check via the experimental feature
CheckImplementationOnly. Adopting it is recommended but will likely require source changes as it’s aligned with the new support of@_implementationOnlyon structs.In this mode we ensure that memory layouts of structs visible to clients are sound. This mostly means that public structs don’t rely on types hidden from the clients via an
@_implementationOnlyimport, in a local member or transitively through a non-public struct.A struct is by default considered exposable to clients and will reject a reference to an
@_implementationOnlydependency unless marked@_implementationOnly. Similarly, a public or non-@_implementationOnlystruct cannot refer to an@_implementationOnlystruct in its layout. If a public or non-@_implementationOnlystruct needs to hold a hidden type it should abstract it away behind a protocol or similar.This check is designed for structs, it remains too permissive for enums and may be too strict for classes.