Skip to content

[concurrency] allow 'get' access to properties from outside the actor #35965

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 7 commits into from
Mar 5, 2021

Conversation

kavon
Copy link
Member

@kavon kavon commented Feb 13, 2021

Resolves rdar://74199653

TODOs:

  • Typechecker modifications to allow async 'get' access to
    • An actor's
      • properties
      • subscripts
    • A global actor's
      • properties
      • subscripts
  • Bonus: improve error messages that say 'async' in a function that does not support concurrency (rdar://72403401)
  • Expand support so that such accesses are valid in global actor and nonisolated contexts.
  • adjust / fix diagnostic message for mutations via subscript
  • Extra testing of typechecker and its various diagnostics
  • Support for lowering such accesses in SILGen
  • More testing of SILGen for global actor properties
  • Make sure we disallow read accesses to subscripts that take an inout argument. Turns out we don't allow inout on subscript parameters in general.
  • Test what happens with property wrappers
  • Test what happens for _modify and _read accessors.
  • Create an execution test.

Something to fix in a later PR:

  • If you accidentally try to access one of these properties (or any implicity-async thing) in a function that is synchronous, you get a very confusing error message that claims that it's not even possible to access it due to isolation but that's not true, it's due to it being a sync context. We need to improve those messages.
  • Test what happens with keypaths

@kavon kavon force-pushed the actor-effectful-properties branch 6 times, most recently from 420aa0c to 59f8462 Compare February 20, 2021 02:12
@kavon
Copy link
Member Author

kavon commented Feb 20, 2021

@swift-ci please smoke test

@kavon kavon force-pushed the actor-effectful-properties branch 4 times, most recently from 125f876 to 7c8030c Compare February 23, 2021 02:24
@kavon
Copy link
Member Author

kavon commented Feb 23, 2021

@swift-ci please smoke test

@kavon
Copy link
Member Author

kavon commented Feb 23, 2021

@swift-ci please smoke test Windows Platform

@kavon kavon force-pushed the actor-effectful-properties branch 8 times, most recently from 33dabd5 to 7fdb0b2 Compare March 3, 2021 02:11
@kavon
Copy link
Member Author

kavon commented Mar 3, 2021

@swift-ci please smoke test

@kavon kavon force-pushed the actor-effectful-properties branch from 7fdb0b2 to 83b88c2 Compare March 4, 2021 01:23
Copy link
Contributor

@ktoso ktoso left a comment

Choose a reason for hiding this comment

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

At least from the typechecking and actor isolation side this looks good to me AFAICS, from what I know about those pieces having worked on those a little bit... May need a proper compiler person to review but looks good :)

@kavon kavon force-pushed the actor-effectful-properties branch from 83b88c2 to 3fd3ba5 Compare March 4, 2021 02:52
@kavon
Copy link
Member Author

kavon commented Mar 4, 2021

@swift-ci please smoke test

kavon added 2 commits March 4, 2021 17:47
The design of things are currently a bit in
 flux, so until that settles down, I thought it
  would be better to just log this as a
   possible clean-up in the future.
@kavon kavon force-pushed the actor-effectful-properties branch from 3fd3ba5 to d67c50c Compare March 5, 2021 01:57
@kavon kavon force-pushed the actor-effectful-properties branch from d67c50c to 0f10638 Compare March 5, 2021 02:22
kavon added 5 commits March 4, 2021 18:37
We now mark some DeclRefExpr and LookupExprs as implicitly async
during typechecking, depending on whether they appear in a context
that is only performing a read / get operation, and whether they
are cross-actor operations.

also resolves rdar://72403401 by improving the error messages
(no more vague "'await' in async context" when its clearly a call!)
…not made it to SILGen

For the dynamic versions of LookupExprs, we do not expect these to be
implicitly async. For the other cases, I simply haven't implemented them
yet.
The strategy for implementing them is integrated with the
PathComponent infrastructure in SILGen in order to correctly
support mixtures of chained accesses and forced optionals, etc.

The actor isolation information is only piped into LValues from
the expressions that might be marked implicitly-async.
@kavon kavon force-pushed the actor-effectful-properties branch from 0f10638 to de0d998 Compare March 5, 2021 02:38
@kavon
Copy link
Member Author

kavon commented Mar 5, 2021

@swift-ci please smoke test and merge

@kavon kavon marked this pull request as ready for review March 5, 2021 02:43
@swift-ci swift-ci merged commit 931c47d into swiftlang:main Mar 5, 2021
@kavon kavon deleted the actor-effectful-properties branch March 8, 2021 22:48
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