Skip to content

Make the test suite compile on Swift 6.4 (explicit capture lists for onCancel closures) - #76

Merged
mansbernhardt merged 1 commit into
mainfrom
fix/sending-closure-tests-swift-6.4
Sep 14, 2026
Merged

mansbernhardt merged 1 commit into
mainfrom
fix/sending-closure-tests-swift-6.4

Conversation

@mansbernhardt

Copy link
Copy Markdown
Collaborator

Summary

  • Swift 6.4 (Xcode 27.0) rejects two withTaskCancellationHandler call sites in CancellationTests and InheritCancellationContextTests with "passing closure as a sending parameter risks causing data races": the onCancel closure implicitly captured a LockIsolated counter that the enclosing model.task { } closure also uses, and the region-isolation checker merges the two regions.
  • An explicit [$count] / [$cancelCount] capture list gives onCancel its own copy of the Sendable reference. No behavioural change.
  • CHANGELOG entry under ### Tests.

Verification

  • scripts/test on Swift 6.4: 869/869 passed (711 + 122 + 7 + 29).
  • Clean swift build --build-tests on 6.4 introduces no new warnings from this change. There are five pre-existing 6.4-toolchain warnings unrelated to it (deprecated withExpectedIssue in TestAccess.swift:1589, two main-actor isolation warnings in SwiftModelSnapshotTests/DebugTests.swift:1417/1420, an unnecessary try in DualRegistrarTests.swift:549, var never mutated in ModelInitAccessorTests.swift:344) — left for a separate pass.

🤖 Generated with Claude Code

…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>
@mansbernhardt
mansbernhardt merged commit 136155e into main Sep 14, 2026
7 checks passed
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.

1 participant