Make the test suite compile on Swift 6.4 (explicit capture lists for onCancel closures) - #76
Merged
Merged
Conversation
…onCancel closures
Swift 6.4's region-isolation checker rejects two `withTaskCancellationHandler`
call sites where the `onCancel` closure implicitly captured a `LockIsolated`
counter also used by the enclosing `model.task { }` closure. An explicit
`[$count]` / `[$cancelCount]` capture list gives `onCancel` its own copy of the
Sendable reference. No behavioural change.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
withTaskCancellationHandlercall sites inCancellationTestsandInheritCancellationContextTestswith "passing closure as asendingparameter risks causing data races": theonCancelclosure implicitly captured aLockIsolatedcounter that the enclosingmodel.task { }closure also uses, and the region-isolation checker merges the two regions.[$count]/[$cancelCount]capture list givesonCancelits own copy of the Sendable reference. No behavioural change.### Tests.Verification
scripts/teston Swift 6.4: 869/869 passed (711 + 122 + 7 + 29).swift build --build-testson 6.4 introduces no new warnings from this change. There are five pre-existing 6.4-toolchain warnings unrelated to it (deprecatedwithExpectedIssueinTestAccess.swift:1589, two main-actor isolation warnings inSwiftModelSnapshotTests/DebugTests.swift:1417/1420, an unnecessarytryinDualRegistrarTests.swift:549,varnever mutated inModelInitAccessorTests.swift:344) — left for a separate pass.🤖 Generated with Claude Code