-
Notifications
You must be signed in to change notification settings - Fork 10.5k
(More) Declaration checker support for tuple conformances #68282
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
slavapestov
merged 11 commits into
swiftlang:main
from
slavapestov:sema-tuple-conformances
Sep 7, 2023
Merged
(More) Declaration checker support for tuple conformances #68282
slavapestov
merged 11 commits into
swiftlang:main
from
slavapestov:sema-tuple-conformances
Sep 7, 2023
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
6b993ea
to
0819ec0
Compare
Either directly, or via a type alias.
This now matches what's actually described in 'Compiling Swift Generics', so of course it must be correct.
0819ec0
to
1a17547
Compare
@swift-ci Please smoke test |
We want that (repeat each Element).[P]A == (repeat (each Element).[P]A), where on the left is type witness projection from the tuple conformance, and on the right is a tuple with a pack expansion.
1a17547
to
7dacc5e
Compare
@swift-ci Please smoke test |
@swift-ci Please 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.
This PR implements a new syntax that doesn't require -parse-stdlib, suggested by @hborla. The nice thing is that we want it to just work anyway, even if/when a new syntax is added:
Or with requirement inference:
This PR also implements enforcement of various semantic restrictions:
Extended type must be
(repeat each T)
whereT
is the type parameter pack of the alias.A tuple extension must define a conformance to exactly one protocol
P
, this conformance must be conditional, and there must be exactly one conditional requirement that is a pack conformance requirement ofT
toP
. You cannot haveextension Tuple: P where repeat each T: Q
, because if T is replaced with a single scalar typeX
, we getX: P where X: Q
, which is false in general unless P inherits from Q.An associated type
A
must be witnessed by(repeat (each T).A)
in the conformance; that is, we require that(repeat each T).A == (repeat (each T).A)
. This restriction is required for a similar reason, for coherence with the one-element vanishing substitution.The above is not enough to ensure coherence. We also need to statically and dynamically unwrap one-element tuple conformances, and prevent devirtualization of certain calls. This will happen in a subsequent PR.