Skip to content

[Concurrency] Implement parsing and semantic analysis of await operator #33199

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
merged 1 commit into from
Jul 30, 2020

Conversation

DougGregor
Copy link
Member

Similar to try, await expressions have no specific semantics of their
own except to indicate that the subexpression contains calls to async
functions, which are suspension points. In this design, there can be
multiple such calls within the subexpression of a given await.

Note that we currently use the keyword __await because await in
this position introduces grammatical ambiguities. We'll wait until
later to sort out the specific grammar we want and evaluate
source-compatibility tradeoffs. It's possible that this kind of prefix
operator isn't what we want anyway.

Similar to `try`, await expressions have no specific semantics of their
own except to indicate that the subexpression contains calls to `async`
functions, which are suspension points. In this design, there can be
multiple such calls within the subexpression of a given `await`.

Note that we currently use the keyword `__await` because `await` in
this position introduces grammatical ambiguities. We'll wait until
later to sort out the specific grammar we want and evaluate
source-compatibility tradeoffs. It's possible that this kind of prefix
operator isn't what we want anyway.
@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor
Copy link
Member Author

Scavenged from #11501, which was good code that just needed a little love after sitting idle for 3 years.

SourceRange highlight;

// Generate more specific messages in some cases.
if (auto e = dyn_cast_or_null<ApplyExpr>(E.dyn_cast<Expr*>()))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Not important, but question is if could this be a place to use getAsExpr<ApplyExpr>(E)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably. I don't think that function existed when this was originally written ;)

Copy link
Collaborator

@theblixguy theblixguy Jul 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LucianoPAlmeida It's defined in ConstraintSystem. I am not sure if it's worth importing it here to use getAsExpr though... (maybe it should be moved into ASTNode?)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah true @theblixguy, so maybe move to a more general header file (as you suggested) would be nice to allow use in other places :)

@DougGregor DougGregor merged commit b4fb4a0 into swiftlang:master Jul 30, 2020
@DougGregor DougGregor deleted the concurrency-await branch July 30, 2020 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants