From 0765168ff24d1a63ac25daae64932e4e04457c21 Mon Sep 17 00:00:00 2001 From: Max Rozdobudko Date: Fri, 14 Aug 2026 19:58:09 +0300 Subject: [PATCH] fix: remove blanket retroactive KeyPath: Sendable conformance MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ThemeKit shipped `extension KeyPath: @retroactive @unchecked Sendable`, a global conformance on a std-lib type ThemeKit does not own. It leaks into every consumer and collides with libraries that manage key-path sendability themselves — notably TCA, which deliberately avoids such a conformance and uses scoped `_Sendable*KeyPath` existentials instead. The collision surfaces as a build failure in TCA-using code: Type 'WritableKeyPath>' does not conform to the 'Sendable' protocol The conformance only existed to let the generated ThemeShadowedStyle / ThemeShapeStyle structs (which store a KeyPath and conform to ShapeStyle: Sendable) synthesize Sendable. Make those generated structs `@unchecked Sendable` instead — sendability is asserted locally and self-contained, since the stored key path is read-only over the Sendable Theme type. Drop the now-redundant per-property `nonisolated` on the key-path storage so it builds under MainActor default isolation. Removes KeyPath+Sendable.swift and its test. The deleted test verified sendability at the std-lib layer; replace it with coverage where it now matters: generator assertions on the emitted declarations, plus compile-time Sendable and cross-actor checks against the generated styles in all four language-mode/isolation fixture targets. Co-Authored-By: Foti Dim Co-Authored-By: Claude Opus 5 (1M context) --- IMPLEMENTATION_DETAILS.md | 2 +- Sources/ThemeKit/KeyPath+Sendable.swift | 1 - .../ThemeShadowedStyleGenerator.swift | 11 +++- .../ThemeShapeStyleGenerator.swift | 9 ++- .../GeneratedCodeCompilationTests.swift | 34 ++++++++++ .../ThemeFileGeneratorTests.swift | 20 ++++++ .../ThemeKitTests/KeyPathSendableTests.swift | 66 ------------------- 7 files changed, 70 insertions(+), 73 deletions(-) delete mode 100644 Sources/ThemeKit/KeyPath+Sendable.swift delete mode 100644 Tests/ThemeKitTests/KeyPathSendableTests.swift diff --git a/IMPLEMENTATION_DETAILS.md b/IMPLEMENTATION_DETAILS.md index 00ff41e..2525ee8 100644 --- a/IMPLEMENTATION_DETAILS.md +++ b/IMPLEMENTATION_DETAILS.md @@ -99,7 +99,7 @@ RoundedRectangle(cornerRadius: 12) Theme tokens are resolved lazily through SwiftUI's `ShapeStyle` protocol. Under the hood, `ThemeShapeStyle