Skip to content

FORGE-1549-Fixes for Swift 6.3#120

Merged
Bryan Malumphy (bmalumphy) merged 1 commit intomainfrom
FORGE-1549-Fix-Swift-6.3-Errors
Mar 30, 2026
Merged

FORGE-1549-Fixes for Swift 6.3#120
Bryan Malumphy (bmalumphy) merged 1 commit intomainfrom
FORGE-1549-Fix-Swift-6.3-Errors

Conversation

@bmalumphy
Copy link
Copy Markdown
Contributor

Fix Swift 6.3 strict concurrency errors in Concurrency.swift

Problem

Under Xcode 26.4 / Swift 6.3 with strict concurrency checking enabled, the asyncMap Publisher extension produced two errors:

  1. "Sending Main actor-isolated value to nonisolated callee risks causing data races"asyncMap was marked @MainActor, making value (of type Output) main-actor-isolated. Future's attemptToFulfill closure is a plain escaping, nonisolated closure, so Swift 6.3 flagged the capture of value as an unsafe send across actor boundaries.

  2. "Passing closure as a 'sending' parameter risks causing data races" — After removing @MainActor, Future.Promise ((Result<T, Failure>) -> Void) is not Sendable. Swift 6.3's Task initializer requires a sending closure, so capturing promise inside Task { } was rejected.

Solution

  • Removed @MainActor from both asyncMap overloads. The functions only build a Combine chain and have no reason to be main-actor-isolated.
  • Added where Output: Sendable on the extension. Values crossing task boundaries must be Sendable — this is the correct Swift 6 constraint.
  • Added @Sendable and T: Sendable to the transform closures, required because they escape into Task.
  • Introduced SendableBox<T>: @unchecked Sendable — a minimal wrapper that allows Future.Promise (a non-Sendable closure) to be captured by Task's sending closure. This is safe because each box is created once per Future, the promise is called exactly once from a single task, and there is no concurrent mutation.

Files Changed

  • sdks/swift/Sources/DittoChatCore/Utilities/Concurrency.swift

@github-actions
Copy link
Copy Markdown
Contributor

🟢 Test Coverage Report - @dittolive/ditto-chat-core

Overall Coverage: 87.93%

Metric Coverage Status
🟢 Lines 86.6% green
🟢 Statements 86.6% green
🟢 Functions 92.45% green
🟢 Branches 86.08% green

📊 View Detailed Coverage Report

ℹ️ Coverage Thresholds
  • 🟢 Excellent (≥ 80%)
  • 🟡 Good (60-79%)
  • 🟠 Fair (40-59%)
  • 🔴 Poor (< 40%)

@github-actions
Copy link
Copy Markdown
Contributor

🟢 Test Coverage Report - @dittolive/ditto-chat-ui

Overall Coverage: 89.67%

Metric Coverage Status
🟢 Lines 91.94% green
🟢 Statements 91.94% green
🟢 Functions 86.11% green
🟢 Branches 88.67% green

📊 View Detailed Coverage Report

ℹ️ Coverage Thresholds
  • 🟢 Excellent (≥ 80%)
  • 🟡 Good (60-79%)
  • 🟠 Fair (40-59%)
  • 🔴 Poor (< 40%)

@bmalumphy Bryan Malumphy (bmalumphy) merged commit 715df17 into main Mar 30, 2026
3 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.

2 participants