[Concurrency] Add async to the Swift type system.#33147
[Concurrency] Add async to the Swift type system.#33147DougGregor merged 7 commits intoswiftlang:masterfrom
async to the Swift type system.#33147Conversation
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`
rjmccall
left a comment
There was a problem hiding this comment.
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.
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
asyncto the type system.asynccan be written as part of afunction type or function declaration, following the parameter list, e.g.,
func doSomeWork() async { ... }
asyncfunctions are distinct from non-asyncfunctions and thereare no conversions amongst them. At present,
asyncfunctions do notdo anything, but this commit fully supports them as a distinct kind
of function throughout:
asyncasyncin declarations and typesasyncinvolving
async.asyncfunction typesasyncfunction typesdiffering
async