-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[5.1] Opaque types prototype #22965
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
jckarter
merged 16 commits into
swiftlang:swift-5.1-branch
from
jckarter:opaque-type-ast-5.1
Feb 28, 2019
Merged
[5.1] Opaque types prototype #22965
jckarter
merged 16 commits into
swiftlang:swift-5.1-branch
from
jckarter:opaque-type-ast-5.1
Feb 28, 2019
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
ecccf77
to
b3642ae
Compare
And maybe allow nested types to live on them.
Explicitly serialize the parent archetype so that it can be any kind of root archetype.
To represent the abstracted interface of an opaque type, we need a generic signature that refines the outer context generic signature with an additional generic parameter representing the underlying type and its exposed constraints. Opaque types also need to be keyed by their originating decl, so that we can treat values of the same opaque type as the same. When we check a FuncDecl with an opaque type specified as its return type, create an OpaqueTypeDecl and associate it with the originating decl. (A representation for *types* derived from the opaque decl will come next.)
It's currently meaningless, and it'll require thought to pass the correct value when it becomes meaningful.
…lt types. This prevents opaque result types from propagating nontrivially into other declarations' types, which may be confusing and create implementation complexities.
b3642ae
to
32f75fd
Compare
@swift-ci Please test |
Build failed |
@swift-ci Please test |
Build failed |
@swift-ci Please test Linux |
Build failed |
@swift-ci Please clean test Linux |
Build failed |
@swift-ci Please clean test Linux |
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.
WIP towards a prototype of an MVP subset of https://forums.swift.org/t/opaque-result-types/15645 . For an initial implementation, this won't include the resilience, second-order
where
constraint, or multiple conditional conformance features proposed in the thread.Limitations include:
__opaque Protocol
or__opaque ProtocolA & ProtocolB [& ProtocolC...]
as placeholder spelling.func
declarations, not properties or closures.where
clause constraints on the opaque type are not yet supported, nor are conditional conformances on the opaque type. However, the protocols in the__opaque
type can be arbitrary protocols, with any number of associated type or Self type requirements.__opaque
types can in turn be inferred as associated types of protocol conformances.Some known issues: