Skip to content

[6.0][Concurrency] Consider isolated key-path components when computing the required isolation of a stored property initializer. #75101

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
Jul 9, 2024

Conversation

hborla
Copy link
Member

@hborla hborla commented Jul 9, 2024

  • Explanation: Stored property initializers are allowed to be isolated to a global actor if the stored property itself shares the same isolation. The code for computing the required isolation of such an initializer did not consider isolated key-paths, which can only be formed within that isolation domain. This change fixes that, and allows isolated key-path components to be used in stored property initializers when the stored property itself is isolated to the same global actor:

    @MainActor
    class C {
      let kp: KeyPath<C, Bool> = \.x // okay because 'kp' is '@MainActor'-isolated
      var x: Bool = true
    }
  • Scope: Only impacts key-paths with isolated path components in stored property initializers under -strict-concurrency=complete or -swift-version 6.

  • Issue: Strict Concurrency warning false positive: MainActor isolated KeyPath #72181

  • Risk: Low. The fix uses an existing mechanism for initializer expression isolation that just wasn't called when checking key-path isolation in the actor isolation checker.

  • Testing: Added a new tests.

  • Reviewer: @ktoso @xedin

  • Main branch PR: [Concurrency] Consider isolated key-path components when computing the required isolation of a stored property initializer. #75091

…e required

isolation of a stored property initializer.

This allows isolated key-path components to be used in stored property
initializers when the stored property itself is isolated to the same
global actor.

(cherry picked from commit c4f6793)
@hborla hborla requested a review from a team as a code owner July 9, 2024 13:55
@hborla
Copy link
Member Author

hborla commented Jul 9, 2024

@swift-ci please test

@hborla hborla merged commit f80a182 into swiftlang:release/6.0 Jul 9, 2024
5 checks passed
@hborla hborla deleted the 6.0-isolated-key-path-init branch July 9, 2024 22:35
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