[6.0][Concurrency] Consider isolated key-path components when computing the required isolation of a stored property initializer. #75101
+43
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
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