Skip to content

[Actors] Permit non-sendable, escaping closures to be actor-isolated. #36698

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 2 commits into from
Apr 2, 2021

Conversation

DougGregor
Copy link
Member

Remove the heuristic that escaping closures cannot be actor-isolated.
This is in line with the long term plan for actor isolation, but opens
up some holes in the short term because Sendable closures are not enforced
throughout the Swift ecosystem.

One significant effect of this change is that we will now, statically,
fail to detect many cases where actor isolation can be broken.

Remove the heuristic that escaping closures cannot be actor-isolated.
This is in line with the long term plan for actor isolation, but opens
up some holes in the short term because Sendable closures are not enforced
throughout the Swift ecosystem.

One significant effect of this change is that we will now, statically,
fail to detect many cases where actor isolation can be broken.
@DougGregor
Copy link
Member Author

@swift-ci please smoke test


// CHECK: acceptEscapingAsyncClosure
// CHECK: closure_expr
// CHECK-NOT:actor-isolated
acceptEscapingAsyncClosure { () async in print("hello") }
// CHEC:actor-isolated
Copy link
Contributor

Choose a reason for hiding this comment

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

typo

Suggested change
// CHEC:actor-isolated
// CHECK:actor-isolated

Copy link
Member Author

Choose a reason for hiding this comment

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

Whoops, thanks!

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.

Unfortunate without Sendable checking but LGTM.

You have one typo in the tests which means it won't check one of the properties :-)

@DougGregor
Copy link
Member Author

@swift-ci please smoke test macOS

@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor
Copy link
Member Author

@swift-ci please smoke test Linux

@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor
Copy link
Member Author

@swift-ci please smoke test macOS

@DougGregor DougGregor merged commit d3d2d75 into swiftlang:main Apr 2, 2021
@DougGregor DougGregor deleted the actor-escaping-isolation branch April 2, 2021 20:01
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.

2 participants