-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Opaque parameters #40993
Opaque parameters #40993
Conversation
@swift-ci please smoke test |
@swift-ci please build toolchain |
Awesome!
That |
Right, thanks |
Linux Toolchain (Ubuntu 16.04) Install command |
10d75b3
to
842ab9d
Compare
@swift-ci please smoke test |
@swift-ci please build toolchain |
Linux Toolchain (Ubuntu 16.04) Install command |
macOS Toolchain Install command |
Implement function parameters of the form `some P` be synthesizing an implicit generic parameter whose requirements come from the opaque type. We then map the opaque type back to the generic parameter, and print as the opaque type. This allows us to write functions with implicit generic parameters: ```swift func f(_: some Collection) { } ``` which is equivalent to: ```swift func f<T: Collection>(_: some T) { } ``` where `T` is an otherwise-unused generic parameter name. All of this is behind the experimental frontend flag `-enable-experimental-opaque-parameters`.
When printing the generic parameters and requirements clauses of declarations that involve opaque parameters, suppress the implicit generic parameters created by the opaque parameters as well as the generic requirements that involve said parameters.
That way, they can be used with Swift interfaces.
842ab9d
to
66e12e8
Compare
@swift-ci please smoke test |
@swift-ci please build toolchain |
Linux Toolchain (Ubuntu 20.04) Install command |
@swift-ci please smoke test |
@swift-ci please build toolchain |
Linux Toolchain (Ubuntu 20.04) Install command |
Implement function parameters of the form
some P
be synthesizing animplicit generic parameter whose requirements come from the opaque
type. We then map the opaque type back to the generic parameter, and
print as the opaque type. This allows us to write functions with
implicit generic parameters:
which is equivalent to:
where
T
is an otherwise-unused generic parameter name.All of this is behind the experimental frontend flag
-enable-experimental-opaque-parameters
.Tracked via rdar://86032821