Skip to content

Conversation

@kavon
Copy link
Member

@kavon kavon commented Jan 13, 2021

Earlier in the design of async/await, we disallowed async initializers for nominal types. There is no fundamental reason for the restriction and it was decided that async initializers would actually be useful (to allow initializers to invoke async functions, for example), and so they appear in the now accepted async/await proposal.

This PR fills in this missing part of the proposal, by allowing initializers to be async.

Resolves rdar://71049563

TODO:

  • Lift restriction in the parser
  • Implement checking missing explicit call to async, zero-arg, designated super initializer
  • Update all existing tests
  • Ensure that asynchronous global-actor-isolated initializers emit the appropriate actor hop.
  • Test coverage
    • typechecker
    • SILGen
    • execution
    • serialization

@kavon kavon force-pushed the async-initializers branch 3 times, most recently from 968da1e to 755bbff Compare April 13, 2021 03:02
@kavon
Copy link
Member Author

kavon commented Apr 13, 2021

@swift-ci please test

@kavon kavon marked this pull request as ready for review April 13, 2021 03:04
@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 755bbffeb3a5f135464c6c0667de798c220581ef

Copy link
Member

@DougGregor DougGregor left a comment

Choose a reason for hiding this comment

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

Looking very good! I'm glad that the code changes were relatively modest.

@kavon kavon force-pushed the async-initializers branch 4 times, most recently from 42f4795 to b818676 Compare April 15, 2021 03:27
@kavon
Copy link
Member Author

kavon commented Apr 15, 2021

@swift-ci Please smoke test and merge

kavon added 5 commits April 15, 2021 10:06
There's a basic prolog emission function, used by value and class constructors, etc, and then there's the full-blown one for functions and closures, which uses the basic version.
implicit calls to an async super.init are not allowed
types correctly hop to the right global-actor in their
prolog.
new phrasing in the error messages to match up with
other phrasing used in messages.
@kavon kavon force-pushed the async-initializers branch from b818676 to 4a32b06 Compare April 15, 2021 17:09
@kavon
Copy link
Member Author

kavon commented Apr 15, 2021

@swift-ci please smoke test and merge

@swift-ci swift-ci merged commit b941835 into swiftlang:main Apr 15, 2021
@kavon kavon deleted the async-initializers branch April 15, 2021 23:54
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.

3 participants