Skip to content

[5.6] Look through defer bodies in actor isolation checking #41077

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
Jan 29, 2022

Conversation

rjmccall
Copy link
Contributor

@rjmccall rjmccall commented Jan 28, 2022

Fixes rdar://88200899

5.6 version of #41067

Explanation: The isolation checker wasn't treating defer bodies as having the same isolation as the enclosing function, meaning that you couldn't e.g. access actor properties from a defer in an actor or call @MainActor functions in a defer in a @MainActor function.
Scope: New code paths are guarded by checks for defer blocks. Emits strictly fewer diagnostics.
Risk: Low
Testing: Existing regression tests, new test specific to defer
Reviewers: @DougGregor, @kavon

@rjmccall rjmccall requested a review from a team as a code owner January 28, 2022 23:18
@rjmccall
Copy link
Contributor Author

Please test with pull request:
swiftlang/llvm-project#3858

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 6f2677451312dad45ce633cef884c85b5e0cf025

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 6f2677451312dad45ce633cef884c85b5e0cf025

@rjmccall rjmccall force-pushed the defer-isolation-5.6 branch from 6f26774 to 62a58ed Compare January 29, 2022 02:50
@rjmccall
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 62a58ede6f278392c0a82bdd05617209b8c0ad1d

@rjmccall rjmccall force-pushed the defer-isolation-5.6 branch from 62a58ed to 169167e Compare January 29, 2022 08:39
@rjmccall
Copy link
Contributor Author

@swift-ci Please test

@rjmccall rjmccall merged commit 189f815 into swiftlang:release/5.6 Jan 29, 2022
@rjmccall rjmccall deleted the defer-isolation-5.6 branch January 29, 2022 18:50
@hebdavepaul0
Copy link

This still seems to be an issue in Swift 5.6: https://forums.swift.org/t/a-bug-cant-defer-actor-isolated-variable-access/50796

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