Skip to content

[6.0][Concurrency] Don't diagnose nonisolated(unsafe) properties during flow isolation. #73311

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

Conversation

hborla
Copy link
Member

@hborla hborla commented Apr 27, 2024

  • Explanation: Flow isolation was not allowing access to nonisolated(unsafe) properties inside actor inits/deinit, leading to warnings in the following code from Cannot access nonisolated(unsafe) var property of actor from init #73294:

    actor A {
      private nonisolated(unsafe) var child: B!
      init() {
        child = B(parent: self) // warning: cannot access property 'child' here in non-isolated initializer; this is an error in the Swift 6 language mode
      }
    }
    actor B {
      unowned nonisolated let parent: any Actor
    
      init(parent: any Actor) {
        self.parent = parent
      }
    }

    This change prevents flow isolation from diagnosing nonisolated(unsafe) properties by checking for ActorIsolation::NonisolatedUnsafe in varIsSafeAcrossActors.

  • Scope: Only impacts access to nonisolated(unsafe) properties inside actor inits and deinits.

  • Risk: Low; this change allows more code to compile under the Swift 6 language mode, and the only impact in other language modes is fewer warnings under -strict-concurrency=complete. This change has no impact on code that uses -strict-concurrency=minimal.

  • Testing: Added a new test.

  • Main branch PR: [Concurrency] Don't diagnose nonisolated(unsafe) properties during flow isolation. #73308

@hborla hborla requested a review from a team as a code owner April 27, 2024 03:53
@hborla
Copy link
Member Author

hborla commented Apr 27, 2024

@swift-ci please test

@hborla hborla merged commit 717c341 into swiftlang:release/6.0 Apr 27, 2024
@hborla hborla deleted the 6.0-flow-isolation-nonisolated-unsafe branch April 27, 2024 17:45
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