-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Concurrency] Add async
to the Swift type system.
#33147
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
Add `async` to the type system. `async` can be written as part of a function type or function declaration, following the parameter list, e.g., func doSomeWork() async { ... } `async` functions are distinct from non-`async` functions and there are no conversions amongst them. At present, `async` functions do not *do* anything, but this commit fully supports them as a distinct kind of function throughout: * Parsing of `async` * AST representation of `async` in declarations and types * Syntactic type representation of `async` * (De-/re-)mangling of function types involving 'async' * Runtime type representation and reconstruction of function types involving `async`. * Dynamic casting restrictions for `async` function types * (De-)serialization of `async` function types * Disabling overriding, witness matching, and conversions with differing `async`
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.
Mostly looks great, thanks!
I don’t think this PR is an appropriate place to discuss syntax changes. Please move the discussion to the Swift forums. The most recent thread around async is here. |
Use the more general name `-enable-experimental-concurrency` instead, since async is one part of the model.
Editorial note: I've deleted all of the comments bike-shedding syntax. Those belong on the forums, in a pitch thread about concurrency designs, not on a pull request for the implementation. |
Add 'async' to the syntax tree for types, function declarations, and the "arrow" expression.
@swift-ci please smoke test |
@swift-ci please smoke test |
@swift-ci smoke test |
SwiftSyntax part of this over at swiftlang/swift-syntax#231 |
@swift-ci please smoke test |
"'throws' may only occur before '->'", ()) | ||
ERROR(rethrows_in_wrong_position,none, | ||
"'rethrows' may only occur before '->'", ()) | ||
ERROR(async_or_throws_in_wrong_position,none, |
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.
Hi @DougGregor – Congrats on this first wave of changes. A small nit here. It would be nice if the diagnostic selector aligned with the diagnostic name. Right now it's backwards. Specifically, the diag is named "async…" and then "…or_throws" but the first selector is "throws". The fix would be:
ERROR(async_or_throws_in_wrong_position,none,
"%select{'async'|'throws'|'rethrows'}0 may only occur before '->'",
(unsigned))
Add
async
to the type system.async
can be written as part of afunction type or function declaration, following the parameter list, e.g.,
func doSomeWork() async { ... }
async
functions are distinct from non-async
functions and thereare no conversions amongst them. At present,
async
functions do notdo anything, but this commit fully supports them as a distinct kind
of function throughout:
async
async
in declarations and typesasync
involving
async
.async
function typesasync
function typesdiffering
async