Skip to content

Commit

Permalink
Clean up key path bitcasting. (#3411)
Browse files Browse the repository at this point in the history
* Clean up key path bitcasting.

* wip

* wip

---------

Co-authored-by: Stephen Celis <[email protected]>
  • Loading branch information
mbrandonw and stephencelis authored Oct 14, 2024
1 parent 4699a1e commit 2d0590b
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 46 deletions.
35 changes: 21 additions & 14 deletions Sources/ComposableArchitecture/Internal/KeyPath+Sendable.swift
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
#if compiler(>=6)
public typealias _AnyKeyPath = any AnyKeyPath & Sendable
public typealias _PartialKeyPath<Root> = any PartialKeyPath<Root> & Sendable
public typealias _KeyPath<Root, Value> = any KeyPath<Root, Value> & Sendable
public typealias _WritableKeyPath<Root, Value> = any WritableKeyPath<Root, Value> & Sendable
public typealias _ReferenceWritableKeyPath<Root, Value> = any ReferenceWritableKeyPath<
public typealias _SendableAnyKeyPath = any AnyKeyPath & Sendable
public typealias _SendablePartialKeyPath<Root> = any PartialKeyPath<Root> & Sendable
public typealias _SendableKeyPath<Root, Value> = any KeyPath<Root, Value> & Sendable
public typealias _SendableWritableKeyPath<Root, Value> = any WritableKeyPath<Root, Value> & Sendable
public typealias _SendableReferenceWritableKeyPath<Root, Value> = any ReferenceWritableKeyPath<
Root, Value
>
& Sendable
public typealias _PartialCaseKeyPath<Root> = any PartialCaseKeyPath<Root> & Sendable
public typealias _CaseKeyPath<Root, Value> = any CaseKeyPath<Root, Value> & Sendable
public typealias _SendablePartialCaseKeyPath<Root> = any PartialCaseKeyPath<Root> & Sendable
public typealias _SendableCaseKeyPath<Root, Value> = any CaseKeyPath<Root, Value> & Sendable
#else
public typealias _AnyKeyPath = AnyKeyPath
public typealias _PartialKeyPath<Root> = PartialKeyPath<Root>
public typealias _KeyPath<Root, Value> = KeyPath<Root, Value>
public typealias _WritableKeyPath<Root, Value> = WritableKeyPath<Root, Value>
public typealias _ReferenceWritableKeyPath<Root, Value> = ReferenceWritableKeyPath<Root, Value>
public typealias _PartialCaseKeyPath<Root> = PartialCaseKeyPath<Root>
public typealias _CaseKeyPath<Root, Value> = CaseKeyPath<Root, Value>
public typealias _SendableAnyKeyPath = AnyKeyPath
public typealias _SendablePartialKeyPath<Root> = PartialKeyPath<Root>
public typealias _SendableKeyPath<Root, Value> = KeyPath<Root, Value>
public typealias _SendableWritableKeyPath<Root, Value> = WritableKeyPath<Root, Value>
public typealias _SendableReferenceWritableKeyPath<Root, Value> = ReferenceWritableKeyPath<Root, Value>
public typealias _SendablePartialCaseKeyPath<Root> = PartialCaseKeyPath<Root>
public typealias _SendableCaseKeyPath<Root, Value> = CaseKeyPath<Root, Value>
#endif

@_transparent
func sendableKeyPath(
_ keyPath: AnyKeyPath
) -> _SendableAnyKeyPath {
unsafeBitCast(keyPath, to: _SendableAnyKeyPath.self)

Check warning on line 26 in Sources/ComposableArchitecture/Internal/KeyPath+Sendable.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (IOS, 15.2)

'unsafeBitCast' from 'AnyKeyPath' to '_SendableAnyKeyPath' (aka 'AnyKeyPath') is unnecessary and can be removed

Check warning on line 26 in Sources/ComposableArchitecture/Internal/KeyPath+Sendable.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (MACOS, 15.2)

'unsafeBitCast' from 'AnyKeyPath' to '_SendableAnyKeyPath' (aka 'AnyKeyPath') is unnecessary and can be removed

Check warning on line 26 in Sources/ComposableArchitecture/Internal/KeyPath+Sendable.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, IOS, 15.4)

'unsafeBitCast' from 'AnyKeyPath' to '_SendableAnyKeyPath' (aka 'AnyKeyPath') is unnecessary and can be removed

Check warning on line 26 in Sources/ComposableArchitecture/Internal/KeyPath+Sendable.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, IOS, 15.4)

'unsafeBitCast' from 'AnyKeyPath' to '_SendableAnyKeyPath' (aka 'AnyKeyPath') is unnecessary and can be removed

Check warning on line 26 in Sources/ComposableArchitecture/Internal/KeyPath+Sendable.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, IOS, 15.4)

'unsafeBitCast' from 'AnyKeyPath' to '_SendableAnyKeyPath' (aka 'AnyKeyPath') is unnecessary and can be removed

Check warning on line 26 in Sources/ComposableArchitecture/Internal/KeyPath+Sendable.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, MAC_CATALYST, 15.4)

'unsafeBitCast' from 'AnyKeyPath' to '_SendableAnyKeyPath' (aka 'AnyKeyPath') is unnecessary and can be removed

Check warning on line 26 in Sources/ComposableArchitecture/Internal/KeyPath+Sendable.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, MAC_CATALYST, 15.4)

'unsafeBitCast' from 'AnyKeyPath' to '_SendableAnyKeyPath' (aka 'AnyKeyPath') is unnecessary and can be removed

Check warning on line 26 in Sources/ComposableArchitecture/Internal/KeyPath+Sendable.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, MAC_CATALYST, 15.4)

'unsafeBitCast' from 'AnyKeyPath' to '_SendableAnyKeyPath' (aka 'AnyKeyPath') is unnecessary and can be removed

Check warning on line 26 in Sources/ComposableArchitecture/Internal/KeyPath+Sendable.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, MACOS, 15.4)

'unsafeBitCast' from 'AnyKeyPath' to '_SendableAnyKeyPath' (aka 'AnyKeyPath') is unnecessary and can be removed

Check warning on line 26 in Sources/ComposableArchitecture/Internal/KeyPath+Sendable.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, MACOS, 15.4)

'unsafeBitCast' from 'AnyKeyPath' to '_SendableAnyKeyPath' (aka 'AnyKeyPath') is unnecessary and can be removed

Check warning on line 26 in Sources/ComposableArchitecture/Internal/KeyPath+Sendable.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, MACOS, 15.4)

'unsafeBitCast' from 'AnyKeyPath' to '_SendableAnyKeyPath' (aka 'AnyKeyPath') is unnecessary and can be removed

Check warning on line 26 in Sources/ComposableArchitecture/Internal/KeyPath+Sendable.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, TVOS, 15.4)

'unsafeBitCast' from 'AnyKeyPath' to '_SendableAnyKeyPath' (aka 'AnyKeyPath') is unnecessary and can be removed

Check warning on line 26 in Sources/ComposableArchitecture/Internal/KeyPath+Sendable.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, TVOS, 15.4)

'unsafeBitCast' from 'AnyKeyPath' to '_SendableAnyKeyPath' (aka 'AnyKeyPath') is unnecessary and can be removed

Check warning on line 26 in Sources/ComposableArchitecture/Internal/KeyPath+Sendable.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, TVOS, 15.4)

'unsafeBitCast' from 'AnyKeyPath' to '_SendableAnyKeyPath' (aka 'AnyKeyPath') is unnecessary and can be removed

Check warning on line 26 in Sources/ComposableArchitecture/Internal/KeyPath+Sendable.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, VISIONOS, 15.4)

'unsafeBitCast' from 'AnyKeyPath' to '_SendableAnyKeyPath' (aka 'AnyKeyPath') is unnecessary and can be removed

Check warning on line 26 in Sources/ComposableArchitecture/Internal/KeyPath+Sendable.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, VISIONOS, 15.4)

'unsafeBitCast' from 'AnyKeyPath' to '_SendableAnyKeyPath' (aka 'AnyKeyPath') is unnecessary and can be removed

Check warning on line 26 in Sources/ComposableArchitecture/Internal/KeyPath+Sendable.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, VISIONOS, 15.4)

'unsafeBitCast' from 'AnyKeyPath' to '_SendableAnyKeyPath' (aka 'AnyKeyPath') is unnecessary and can be removed

Check warning on line 26 in Sources/ComposableArchitecture/Internal/KeyPath+Sendable.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, WATCHOS, 15.4)

'unsafeBitCast' from 'AnyKeyPath' to '_SendableAnyKeyPath' (aka 'AnyKeyPath') is unnecessary and can be removed

Check warning on line 26 in Sources/ComposableArchitecture/Internal/KeyPath+Sendable.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, WATCHOS, 15.4)

'unsafeBitCast' from 'AnyKeyPath' to '_SendableAnyKeyPath' (aka 'AnyKeyPath') is unnecessary and can be removed

Check warning on line 26 in Sources/ComposableArchitecture/Internal/KeyPath+Sendable.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, WATCHOS, 15.4)

'unsafeBitCast' from 'AnyKeyPath' to '_SendableAnyKeyPath' (aka 'AnyKeyPath') is unnecessary and can be removed

Check warning on line 26 in Sources/ComposableArchitecture/Internal/KeyPath+Sendable.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, WATCHOS, 15.4)

'unsafeBitCast' from 'AnyKeyPath' to '_SendableAnyKeyPath' (aka 'AnyKeyPath') is unnecessary and can be removed
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ extension UIBindable {

extension BindingAction {
public static func set<Value: Equatable & Sendable>(
_ keyPath: _WritableKeyPath<Root, Value>,
_ keyPath: _SendableWritableKeyPath<Root, Value>,
_ value: Value
) -> Self where Root: ObservableState {
.init(
Expand Down Expand Up @@ -116,7 +116,7 @@ extension BindingAction {

extension BindableAction where State: ObservableState {
fileprivate static func set<Value: Equatable & Sendable>(
_ keyPath: _WritableKeyPath<State, Value>,
_ keyPath: _SendableWritableKeyPath<State, Value>,
_ value: Value,
isInvalidated: (@MainActor @Sendable () -> Bool)?
) -> Self {
Expand Down Expand Up @@ -150,7 +150,7 @@ extension BindableAction where State: ObservableState {
}

public static func set<Value: Equatable & Sendable>(
_ keyPath: _WritableKeyPath<State, Value>,
_ keyPath: _SendableWritableKeyPath<State, Value>,
_ value: Value
) -> Self {
self.set(keyPath, value, isInvalidated: nil)
Expand All @@ -159,7 +159,7 @@ extension BindableAction where State: ObservableState {

extension Store where State: ObservableState, Action: BindableAction, Action.State == State {
public subscript<Value: Equatable & Sendable>(
dynamicMember keyPath: _WritableKeyPath<State, Value>
dynamicMember keyPath: _SendableWritableKeyPath<State, Value>
) -> Value {
get { self.state[keyPath: keyPath] }
set {
Expand Down Expand Up @@ -195,7 +195,7 @@ where
Action.ViewAction.State == State
{
public subscript<Value: Equatable & Sendable>(
dynamicMember keyPath: _WritableKeyPath<State, Value>
dynamicMember keyPath: _SendableWritableKeyPath<State, Value>
) -> Value {
get { self.state[keyPath: keyPath] }
set {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ extension PresentationAction: CasePathable {
}

public subscript<AppendedAction>(
dynamicMember keyPath: _CaseKeyPath<Action, AppendedAction>
dynamicMember keyPath: _SendableCaseKeyPath<Action, AppendedAction>
) -> AnyCasePath<PresentationAction, AppendedAction>
where Action: CasePathable {
AnyCasePath<PresentationAction, AppendedAction>(
Expand All @@ -307,7 +307,7 @@ extension PresentationAction: CasePathable {

@_disfavoredOverload
public subscript<AppendedAction>(
dynamicMember keyPath: _CaseKeyPath<Action, AppendedAction>
dynamicMember keyPath: _SendableCaseKeyPath<Action, AppendedAction>
) -> AnyCasePath<PresentationAction, PresentationAction<AppendedAction>>
where Action: CasePathable {
AnyCasePath<PresentationAction, PresentationAction<AppendedAction>>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ extension PersistenceReaderKey {
/// - Parameter key: A string key identifying a value to share in memory.
/// - Returns: A persistence key.
public static func appStorage<Value>(
_ keyPath: _ReferenceWritableKeyPath<UserDefaults, Value>
_ keyPath: _SendableReferenceWritableKeyPath<UserDefaults, Value>
) -> Self where Self == AppStorageKeyPathKey<Value> {
AppStorageKeyPathKey(keyPath)
}
Expand All @@ -25,10 +25,10 @@ extension PersistenceReaderKey {
///
/// See ``PersistenceReaderKey/appStorage(_:)-5jsie`` to create values of this type.
public struct AppStorageKeyPathKey<Value: Sendable>: Sendable {
private let keyPath: _ReferenceWritableKeyPath<UserDefaults, Value>
private let keyPath: _SendableReferenceWritableKeyPath<UserDefaults, Value>

Check warning on line 28 in Sources/ComposableArchitecture/SharedState/PersistenceKey/AppStorageKeyPathKey.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (IOS, 15.2)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'AppStorageKeyPathKey' has non-sendable type '_SendableReferenceWritableKeyPath<UserDefaults, Value>' (aka 'ReferenceWritableKeyPath<UserDefaults, Value>')

Check warning on line 28 in Sources/ComposableArchitecture/SharedState/PersistenceKey/AppStorageKeyPathKey.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (IOS, 15.2)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'AppStorageKeyPathKey' has non-sendable type '_SendableReferenceWritableKeyPath<UserDefaults, Value>' (aka 'ReferenceWritableKeyPath<UserDefaults, Value>')

Check warning on line 28 in Sources/ComposableArchitecture/SharedState/PersistenceKey/AppStorageKeyPathKey.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (MACOS, 15.2)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'AppStorageKeyPathKey' has non-sendable type '_SendableReferenceWritableKeyPath<UserDefaults, Value>' (aka 'ReferenceWritableKeyPath<UserDefaults, Value>')

Check warning on line 28 in Sources/ComposableArchitecture/SharedState/PersistenceKey/AppStorageKeyPathKey.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (MACOS, 15.2)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'AppStorageKeyPathKey' has non-sendable type '_SendableReferenceWritableKeyPath<UserDefaults, Value>' (aka 'ReferenceWritableKeyPath<UserDefaults, Value>')

Check warning on line 28 in Sources/ComposableArchitecture/SharedState/PersistenceKey/AppStorageKeyPathKey.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, IOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'AppStorageKeyPathKey' has non-sendable type '_SendableReferenceWritableKeyPath<UserDefaults, Value>' (aka 'ReferenceWritableKeyPath<UserDefaults, Value>')

Check warning on line 28 in Sources/ComposableArchitecture/SharedState/PersistenceKey/AppStorageKeyPathKey.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, IOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'AppStorageKeyPathKey' has non-sendable type '_SendableReferenceWritableKeyPath<UserDefaults, Value>' (aka 'ReferenceWritableKeyPath<UserDefaults, Value>')

Check warning on line 28 in Sources/ComposableArchitecture/SharedState/PersistenceKey/AppStorageKeyPathKey.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, IOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'AppStorageKeyPathKey' has non-sendable type '_SendableReferenceWritableKeyPath<UserDefaults, Value>' (aka 'ReferenceWritableKeyPath<UserDefaults, Value>')

Check warning on line 28 in Sources/ComposableArchitecture/SharedState/PersistenceKey/AppStorageKeyPathKey.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, IOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'AppStorageKeyPathKey' has non-sendable type '_SendableReferenceWritableKeyPath<UserDefaults, Value>' (aka 'ReferenceWritableKeyPath<UserDefaults, Value>')

Check warning on line 28 in Sources/ComposableArchitecture/SharedState/PersistenceKey/AppStorageKeyPathKey.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, MAC_CATALYST, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'AppStorageKeyPathKey' has non-sendable type '_SendableReferenceWritableKeyPath<UserDefaults, Value>' (aka 'ReferenceWritableKeyPath<UserDefaults, Value>')

Check warning on line 28 in Sources/ComposableArchitecture/SharedState/PersistenceKey/AppStorageKeyPathKey.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, MAC_CATALYST, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'AppStorageKeyPathKey' has non-sendable type '_SendableReferenceWritableKeyPath<UserDefaults, Value>' (aka 'ReferenceWritableKeyPath<UserDefaults, Value>')

Check warning on line 28 in Sources/ComposableArchitecture/SharedState/PersistenceKey/AppStorageKeyPathKey.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, MAC_CATALYST, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'AppStorageKeyPathKey' has non-sendable type '_SendableReferenceWritableKeyPath<UserDefaults, Value>' (aka 'ReferenceWritableKeyPath<UserDefaults, Value>')

Check warning on line 28 in Sources/ComposableArchitecture/SharedState/PersistenceKey/AppStorageKeyPathKey.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, MAC_CATALYST, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'AppStorageKeyPathKey' has non-sendable type '_SendableReferenceWritableKeyPath<UserDefaults, Value>' (aka 'ReferenceWritableKeyPath<UserDefaults, Value>')

Check warning on line 28 in Sources/ComposableArchitecture/SharedState/PersistenceKey/AppStorageKeyPathKey.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, MACOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'AppStorageKeyPathKey' has non-sendable type '_SendableReferenceWritableKeyPath<UserDefaults, Value>' (aka 'ReferenceWritableKeyPath<UserDefaults, Value>')

Check warning on line 28 in Sources/ComposableArchitecture/SharedState/PersistenceKey/AppStorageKeyPathKey.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, MACOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'AppStorageKeyPathKey' has non-sendable type '_SendableReferenceWritableKeyPath<UserDefaults, Value>' (aka 'ReferenceWritableKeyPath<UserDefaults, Value>')

Check warning on line 28 in Sources/ComposableArchitecture/SharedState/PersistenceKey/AppStorageKeyPathKey.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, MACOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'AppStorageKeyPathKey' has non-sendable type '_SendableReferenceWritableKeyPath<UserDefaults, Value>' (aka 'ReferenceWritableKeyPath<UserDefaults, Value>')

Check warning on line 28 in Sources/ComposableArchitecture/SharedState/PersistenceKey/AppStorageKeyPathKey.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, MACOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'AppStorageKeyPathKey' has non-sendable type '_SendableReferenceWritableKeyPath<UserDefaults, Value>' (aka 'ReferenceWritableKeyPath<UserDefaults, Value>')

Check warning on line 28 in Sources/ComposableArchitecture/SharedState/PersistenceKey/AppStorageKeyPathKey.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, TVOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'AppStorageKeyPathKey' has non-sendable type '_SendableReferenceWritableKeyPath<UserDefaults, Value>' (aka 'ReferenceWritableKeyPath<UserDefaults, Value>')

Check warning on line 28 in Sources/ComposableArchitecture/SharedState/PersistenceKey/AppStorageKeyPathKey.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, TVOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'AppStorageKeyPathKey' has non-sendable type '_SendableReferenceWritableKeyPath<UserDefaults, Value>' (aka 'ReferenceWritableKeyPath<UserDefaults, Value>')

Check warning on line 28 in Sources/ComposableArchitecture/SharedState/PersistenceKey/AppStorageKeyPathKey.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, TVOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'AppStorageKeyPathKey' has non-sendable type '_SendableReferenceWritableKeyPath<UserDefaults, Value>' (aka 'ReferenceWritableKeyPath<UserDefaults, Value>')

Check warning on line 28 in Sources/ComposableArchitecture/SharedState/PersistenceKey/AppStorageKeyPathKey.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, TVOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'AppStorageKeyPathKey' has non-sendable type '_SendableReferenceWritableKeyPath<UserDefaults, Value>' (aka 'ReferenceWritableKeyPath<UserDefaults, Value>')

Check warning on line 28 in Sources/ComposableArchitecture/SharedState/PersistenceKey/AppStorageKeyPathKey.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, VISIONOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'AppStorageKeyPathKey' has non-sendable type '_SendableReferenceWritableKeyPath<UserDefaults, Value>' (aka 'ReferenceWritableKeyPath<UserDefaults, Value>')

Check warning on line 28 in Sources/ComposableArchitecture/SharedState/PersistenceKey/AppStorageKeyPathKey.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, VISIONOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'AppStorageKeyPathKey' has non-sendable type '_SendableReferenceWritableKeyPath<UserDefaults, Value>' (aka 'ReferenceWritableKeyPath<UserDefaults, Value>')

Check warning on line 28 in Sources/ComposableArchitecture/SharedState/PersistenceKey/AppStorageKeyPathKey.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, VISIONOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'AppStorageKeyPathKey' has non-sendable type '_SendableReferenceWritableKeyPath<UserDefaults, Value>' (aka 'ReferenceWritableKeyPath<UserDefaults, Value>')

Check warning on line 28 in Sources/ComposableArchitecture/SharedState/PersistenceKey/AppStorageKeyPathKey.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, VISIONOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'AppStorageKeyPathKey' has non-sendable type '_SendableReferenceWritableKeyPath<UserDefaults, Value>' (aka 'ReferenceWritableKeyPath<UserDefaults, Value>')

Check warning on line 28 in Sources/ComposableArchitecture/SharedState/PersistenceKey/AppStorageKeyPathKey.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, WATCHOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'AppStorageKeyPathKey' has non-sendable type '_SendableReferenceWritableKeyPath<UserDefaults, Value>' (aka 'ReferenceWritableKeyPath<UserDefaults, Value>')

Check warning on line 28 in Sources/ComposableArchitecture/SharedState/PersistenceKey/AppStorageKeyPathKey.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, WATCHOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'AppStorageKeyPathKey' has non-sendable type '_SendableReferenceWritableKeyPath<UserDefaults, Value>' (aka 'ReferenceWritableKeyPath<UserDefaults, Value>')

Check warning on line 28 in Sources/ComposableArchitecture/SharedState/PersistenceKey/AppStorageKeyPathKey.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, WATCHOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'AppStorageKeyPathKey' has non-sendable type '_SendableReferenceWritableKeyPath<UserDefaults, Value>' (aka 'ReferenceWritableKeyPath<UserDefaults, Value>')

Check warning on line 28 in Sources/ComposableArchitecture/SharedState/PersistenceKey/AppStorageKeyPathKey.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, WATCHOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'AppStorageKeyPathKey' has non-sendable type '_SendableReferenceWritableKeyPath<UserDefaults, Value>' (aka 'ReferenceWritableKeyPath<UserDefaults, Value>')

Check warning on line 28 in Sources/ComposableArchitecture/SharedState/PersistenceKey/AppStorageKeyPathKey.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, WATCHOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'AppStorageKeyPathKey' has non-sendable type '_SendableReferenceWritableKeyPath<UserDefaults, Value>' (aka 'ReferenceWritableKeyPath<UserDefaults, Value>')
private let store: UncheckedSendable<UserDefaults>

public init(_ keyPath: _ReferenceWritableKeyPath<UserDefaults, Value>) {
public init(_ keyPath: _SendableReferenceWritableKeyPath<UserDefaults, Value>) {
@Dependency(\.defaultAppStorage) var store
self.keyPath = keyPath
self.store = UncheckedSendable(store)
Expand Down
19 changes: 8 additions & 11 deletions Sources/ComposableArchitecture/SharedState/Shared.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import IssueReporting
@propertyWrapper
public struct Shared<Value: Sendable>: Sendable {
private let reference: any Reference
private let keyPath: _AnyKeyPath
private let keyPath: _SendableAnyKeyPath

Check warning on line 17 in Sources/ComposableArchitecture/SharedState/Shared.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (IOS, 15.2)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'Shared' has non-sendable type '_SendableAnyKeyPath' (aka 'AnyKeyPath')

Check warning on line 17 in Sources/ComposableArchitecture/SharedState/Shared.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (IOS, 15.2)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'Shared' has non-sendable type '_SendableAnyKeyPath' (aka 'AnyKeyPath')

Check warning on line 17 in Sources/ComposableArchitecture/SharedState/Shared.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (MACOS, 15.2)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'Shared' has non-sendable type '_SendableAnyKeyPath' (aka 'AnyKeyPath')

Check warning on line 17 in Sources/ComposableArchitecture/SharedState/Shared.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (MACOS, 15.2)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'Shared' has non-sendable type '_SendableAnyKeyPath' (aka 'AnyKeyPath')

Check warning on line 17 in Sources/ComposableArchitecture/SharedState/Shared.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, IOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'Shared' has non-sendable type '_SendableAnyKeyPath' (aka 'AnyKeyPath')

Check warning on line 17 in Sources/ComposableArchitecture/SharedState/Shared.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, IOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'Shared' has non-sendable type '_SendableAnyKeyPath' (aka 'AnyKeyPath')

Check warning on line 17 in Sources/ComposableArchitecture/SharedState/Shared.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, IOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'Shared' has non-sendable type '_SendableAnyKeyPath' (aka 'AnyKeyPath')

Check warning on line 17 in Sources/ComposableArchitecture/SharedState/Shared.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, IOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'Shared' has non-sendable type '_SendableAnyKeyPath' (aka 'AnyKeyPath')

Check warning on line 17 in Sources/ComposableArchitecture/SharedState/Shared.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, MAC_CATALYST, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'Shared' has non-sendable type '_SendableAnyKeyPath' (aka 'AnyKeyPath')

Check warning on line 17 in Sources/ComposableArchitecture/SharedState/Shared.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, MAC_CATALYST, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'Shared' has non-sendable type '_SendableAnyKeyPath' (aka 'AnyKeyPath')

Check warning on line 17 in Sources/ComposableArchitecture/SharedState/Shared.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, MAC_CATALYST, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'Shared' has non-sendable type '_SendableAnyKeyPath' (aka 'AnyKeyPath')

Check warning on line 17 in Sources/ComposableArchitecture/SharedState/Shared.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, MAC_CATALYST, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'Shared' has non-sendable type '_SendableAnyKeyPath' (aka 'AnyKeyPath')

Check warning on line 17 in Sources/ComposableArchitecture/SharedState/Shared.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, MACOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'Shared' has non-sendable type '_SendableAnyKeyPath' (aka 'AnyKeyPath')

Check warning on line 17 in Sources/ComposableArchitecture/SharedState/Shared.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, MACOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'Shared' has non-sendable type '_SendableAnyKeyPath' (aka 'AnyKeyPath')

Check warning on line 17 in Sources/ComposableArchitecture/SharedState/Shared.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, MACOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'Shared' has non-sendable type '_SendableAnyKeyPath' (aka 'AnyKeyPath')

Check warning on line 17 in Sources/ComposableArchitecture/SharedState/Shared.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, MACOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'Shared' has non-sendable type '_SendableAnyKeyPath' (aka 'AnyKeyPath')

Check warning on line 17 in Sources/ComposableArchitecture/SharedState/Shared.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, TVOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'Shared' has non-sendable type '_SendableAnyKeyPath' (aka 'AnyKeyPath')

Check warning on line 17 in Sources/ComposableArchitecture/SharedState/Shared.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, TVOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'Shared' has non-sendable type '_SendableAnyKeyPath' (aka 'AnyKeyPath')

Check warning on line 17 in Sources/ComposableArchitecture/SharedState/Shared.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, TVOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'Shared' has non-sendable type '_SendableAnyKeyPath' (aka 'AnyKeyPath')

Check warning on line 17 in Sources/ComposableArchitecture/SharedState/Shared.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, TVOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'Shared' has non-sendable type '_SendableAnyKeyPath' (aka 'AnyKeyPath')

Check warning on line 17 in Sources/ComposableArchitecture/SharedState/Shared.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, VISIONOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'Shared' has non-sendable type '_SendableAnyKeyPath' (aka 'AnyKeyPath')

Check warning on line 17 in Sources/ComposableArchitecture/SharedState/Shared.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, VISIONOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'Shared' has non-sendable type '_SendableAnyKeyPath' (aka 'AnyKeyPath')

Check warning on line 17 in Sources/ComposableArchitecture/SharedState/Shared.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, VISIONOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'Shared' has non-sendable type '_SendableAnyKeyPath' (aka 'AnyKeyPath')

Check warning on line 17 in Sources/ComposableArchitecture/SharedState/Shared.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, VISIONOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'Shared' has non-sendable type '_SendableAnyKeyPath' (aka 'AnyKeyPath')

Check warning on line 17 in Sources/ComposableArchitecture/SharedState/Shared.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, WATCHOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'Shared' has non-sendable type '_SendableAnyKeyPath' (aka 'AnyKeyPath')

Check warning on line 17 in Sources/ComposableArchitecture/SharedState/Shared.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, WATCHOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'Shared' has non-sendable type '_SendableAnyKeyPath' (aka 'AnyKeyPath')

Check warning on line 17 in Sources/ComposableArchitecture/SharedState/Shared.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, WATCHOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'Shared' has non-sendable type '_SendableAnyKeyPath' (aka 'AnyKeyPath')

Check warning on line 17 in Sources/ComposableArchitecture/SharedState/Shared.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, WATCHOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'Shared' has non-sendable type '_SendableAnyKeyPath' (aka 'AnyKeyPath')

init(reference: any Reference, keyPath: _AnyKeyPath) {
init(reference: any Reference, keyPath: _SendableAnyKeyPath) {
self.reference = reference
self.keyPath = keyPath
}
Expand Down Expand Up @@ -64,10 +64,9 @@ public struct Shared<Value: Sendable>: Sendable {
reference: base.reference,
// NB: Can get rid of bitcast when this is fixed:
// https://github.com/swiftlang/swift/issues/75531
keyPath: unsafeBitCast(
keyPath: sendableKeyPath(
(base.keyPath as AnyKeyPath)
.appending(path: \Value?.[default: DefaultSubscript(initialValue)])!,
to: _AnyKeyPath.self
.appending(path: \Value?.[default: DefaultSubscript(initialValue)])!
)
)
}
Expand Down Expand Up @@ -180,9 +179,8 @@ public struct Shared<Value: Sendable>: Sendable {
reference: self.reference,
// NB: Can get rid of bitcast when this is fixed:
// https://github.com/swiftlang/swift/issues/75531
keyPath: unsafeBitCast(
(self.keyPath as AnyKeyPath).appending(path: keyPath)!,
to: _AnyKeyPath.self
keyPath: sendableKeyPath(
(self.keyPath as AnyKeyPath).appending(path: keyPath)!
)
)
}
Expand Down Expand Up @@ -463,9 +461,8 @@ extension Shared {
reference: self.reference,
// NB: Can get rid of bitcast when this is fixed:
// https://github.com/swiftlang/swift/issues/75531
keyPath: unsafeBitCast(
(self.keyPath as AnyKeyPath).appending(path: keyPath)!,
to: _AnyKeyPath.self
keyPath: sendableKeyPath(
(self.keyPath as AnyKeyPath).appending(path: keyPath)!
)
)
}
Expand Down
18 changes: 9 additions & 9 deletions Sources/ComposableArchitecture/SwiftUI/Binding.swift
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,15 @@ extension BindingState: Sendable where Value: Sendable {}
///
/// Read <doc:Bindings> for more information.
public struct BindingAction<Root>: CasePathable, Equatable, Sendable {
public let keyPath: _PartialKeyPath<Root>
public let keyPath: _SendablePartialKeyPath<Root>

Check warning on line 147 in Sources/ComposableArchitecture/SwiftUI/Binding.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (IOS, 15.2)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'BindingAction' has non-sendable type '_SendablePartialKeyPath<Root>' (aka 'PartialKeyPath<Root>')

Check warning on line 147 in Sources/ComposableArchitecture/SwiftUI/Binding.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (IOS, 15.2)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'BindingAction' has non-sendable type '_SendablePartialKeyPath<Root>' (aka 'PartialKeyPath<Root>')

Check warning on line 147 in Sources/ComposableArchitecture/SwiftUI/Binding.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (MACOS, 15.2)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'BindingAction' has non-sendable type '_SendablePartialKeyPath<Root>' (aka 'PartialKeyPath<Root>')

Check warning on line 147 in Sources/ComposableArchitecture/SwiftUI/Binding.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (MACOS, 15.2)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'BindingAction' has non-sendable type '_SendablePartialKeyPath<Root>' (aka 'PartialKeyPath<Root>')

Check warning on line 147 in Sources/ComposableArchitecture/SwiftUI/Binding.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, IOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'BindingAction' has non-sendable type '_SendablePartialKeyPath<Root>' (aka 'PartialKeyPath<Root>')

Check warning on line 147 in Sources/ComposableArchitecture/SwiftUI/Binding.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, IOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'BindingAction' has non-sendable type '_SendablePartialKeyPath<Root>' (aka 'PartialKeyPath<Root>')

Check warning on line 147 in Sources/ComposableArchitecture/SwiftUI/Binding.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, IOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'BindingAction' has non-sendable type '_SendablePartialKeyPath<Root>' (aka 'PartialKeyPath<Root>')

Check warning on line 147 in Sources/ComposableArchitecture/SwiftUI/Binding.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, IOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'BindingAction' has non-sendable type '_SendablePartialKeyPath<Root>' (aka 'PartialKeyPath<Root>')

Check warning on line 147 in Sources/ComposableArchitecture/SwiftUI/Binding.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, MAC_CATALYST, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'BindingAction' has non-sendable type '_SendablePartialKeyPath<Root>' (aka 'PartialKeyPath<Root>')

Check warning on line 147 in Sources/ComposableArchitecture/SwiftUI/Binding.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, MAC_CATALYST, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'BindingAction' has non-sendable type '_SendablePartialKeyPath<Root>' (aka 'PartialKeyPath<Root>')

Check warning on line 147 in Sources/ComposableArchitecture/SwiftUI/Binding.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, MAC_CATALYST, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'BindingAction' has non-sendable type '_SendablePartialKeyPath<Root>' (aka 'PartialKeyPath<Root>')

Check warning on line 147 in Sources/ComposableArchitecture/SwiftUI/Binding.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, MAC_CATALYST, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'BindingAction' has non-sendable type '_SendablePartialKeyPath<Root>' (aka 'PartialKeyPath<Root>')

Check warning on line 147 in Sources/ComposableArchitecture/SwiftUI/Binding.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, MACOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'BindingAction' has non-sendable type '_SendablePartialKeyPath<Root>' (aka 'PartialKeyPath<Root>')

Check warning on line 147 in Sources/ComposableArchitecture/SwiftUI/Binding.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, MACOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'BindingAction' has non-sendable type '_SendablePartialKeyPath<Root>' (aka 'PartialKeyPath<Root>')

Check warning on line 147 in Sources/ComposableArchitecture/SwiftUI/Binding.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, MACOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'BindingAction' has non-sendable type '_SendablePartialKeyPath<Root>' (aka 'PartialKeyPath<Root>')

Check warning on line 147 in Sources/ComposableArchitecture/SwiftUI/Binding.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, MACOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'BindingAction' has non-sendable type '_SendablePartialKeyPath<Root>' (aka 'PartialKeyPath<Root>')

Check warning on line 147 in Sources/ComposableArchitecture/SwiftUI/Binding.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, TVOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'BindingAction' has non-sendable type '_SendablePartialKeyPath<Root>' (aka 'PartialKeyPath<Root>')

Check warning on line 147 in Sources/ComposableArchitecture/SwiftUI/Binding.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, TVOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'BindingAction' has non-sendable type '_SendablePartialKeyPath<Root>' (aka 'PartialKeyPath<Root>')

Check warning on line 147 in Sources/ComposableArchitecture/SwiftUI/Binding.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, TVOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'BindingAction' has non-sendable type '_SendablePartialKeyPath<Root>' (aka 'PartialKeyPath<Root>')

Check warning on line 147 in Sources/ComposableArchitecture/SwiftUI/Binding.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, TVOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'BindingAction' has non-sendable type '_SendablePartialKeyPath<Root>' (aka 'PartialKeyPath<Root>')

Check warning on line 147 in Sources/ComposableArchitecture/SwiftUI/Binding.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, VISIONOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'BindingAction' has non-sendable type '_SendablePartialKeyPath<Root>' (aka 'PartialKeyPath<Root>')

Check warning on line 147 in Sources/ComposableArchitecture/SwiftUI/Binding.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, VISIONOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'BindingAction' has non-sendable type '_SendablePartialKeyPath<Root>' (aka 'PartialKeyPath<Root>')

Check warning on line 147 in Sources/ComposableArchitecture/SwiftUI/Binding.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, VISIONOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'BindingAction' has non-sendable type '_SendablePartialKeyPath<Root>' (aka 'PartialKeyPath<Root>')

Check warning on line 147 in Sources/ComposableArchitecture/SwiftUI/Binding.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, VISIONOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'BindingAction' has non-sendable type '_SendablePartialKeyPath<Root>' (aka 'PartialKeyPath<Root>')

Check warning on line 147 in Sources/ComposableArchitecture/SwiftUI/Binding.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, WATCHOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'BindingAction' has non-sendable type '_SendablePartialKeyPath<Root>' (aka 'PartialKeyPath<Root>')

Check warning on line 147 in Sources/ComposableArchitecture/SwiftUI/Binding.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, WATCHOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'BindingAction' has non-sendable type '_SendablePartialKeyPath<Root>' (aka 'PartialKeyPath<Root>')

Check warning on line 147 in Sources/ComposableArchitecture/SwiftUI/Binding.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, WATCHOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'BindingAction' has non-sendable type '_SendablePartialKeyPath<Root>' (aka 'PartialKeyPath<Root>')

Check warning on line 147 in Sources/ComposableArchitecture/SwiftUI/Binding.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (test, WATCHOS, 15.4)

stored property 'keyPath' of 'Sendable'-conforming generic struct 'BindingAction' has non-sendable type '_SendablePartialKeyPath<Root>' (aka 'PartialKeyPath<Root>')

@usableFromInline
let set: @Sendable (inout Root) -> Void
let value: any Sendable
let valueIsEqualTo: @Sendable (Any) -> Bool

init(
keyPath: _PartialKeyPath<Root>,
keyPath: _SendablePartialKeyPath<Root>,
set: @escaping @Sendable (inout Root) -> Void,
value: any Sendable,
valueIsEqualTo: @escaping @Sendable (Any) -> Bool
Expand All @@ -174,7 +174,7 @@ public struct BindingAction<Root>: CasePathable, Equatable, Sendable {
@dynamicMemberLookup
public struct AllCasePaths {
public subscript<Value: Equatable & Sendable>(
dynamicMember keyPath: _WritableKeyPath<Root, Value>
dynamicMember keyPath: _SendableWritableKeyPath<Root, Value>
) -> AnyCasePath<BindingAction, Value> where Root: ObservableState {
AnyCasePath(
embed: { .set(keyPath, $0) },
Expand All @@ -183,7 +183,7 @@ public struct BindingAction<Root>: CasePathable, Equatable, Sendable {
}

public subscript<Value: Equatable & Sendable>(
dynamicMember keyPath: _WritableKeyPath<Root, BindingState<Value>>
dynamicMember keyPath: _SendableWritableKeyPath<Root, BindingState<Value>>
) -> AnyCasePath<BindingAction, Value> {
AnyCasePath(
embed: { .set(keyPath, $0) },
Expand All @@ -204,7 +204,7 @@ extension BindingAction {
/// - Returns: An action that describes simple mutations to some root state at a writable key
/// path.
public static func set<Value: Equatable & Sendable>(
_ keyPath: _WritableKeyPath<Root, BindingState<Value>>,
_ keyPath: _SendableWritableKeyPath<Root, BindingState<Value>>,
_ value: Value
) -> Self {
return .init(
Expand Down Expand Up @@ -234,7 +234,7 @@ extension BindingAction {
}

init<Value: Equatable & Sendable>(
keyPath: _WritableKeyPath<Root, BindingState<Value>>,
keyPath: _SendableWritableKeyPath<Root, BindingState<Value>>,
set: @escaping @Sendable (_ state: inout Root) -> Void,
value: Value
) {
Expand Down Expand Up @@ -290,7 +290,7 @@ extension BindableAction {
///
/// - Returns: A binding action.
public static func set<Value: Equatable & Sendable>(
_ keyPath: _WritableKeyPath<State, BindingState<Value>>,
_ keyPath: _SendableWritableKeyPath<State, BindingState<Value>>,
_ value: Value
) -> Self {
self.binding(.set(keyPath, value))
Expand All @@ -299,7 +299,7 @@ extension BindableAction {

extension ViewStore where ViewAction: BindableAction, ViewAction.State == ViewState {
public subscript<Value: Equatable & Sendable>(
dynamicMember keyPath: _WritableKeyPath<ViewState, BindingState<Value>>
dynamicMember keyPath: _SendableWritableKeyPath<ViewState, BindingState<Value>>
) -> Binding<Value> {
self.binding(
get: { $0[keyPath: keyPath].wrappedValue },
Expand Down Expand Up @@ -454,7 +454,7 @@ public struct BindingViewStore<State> {
}

public subscript<Value: Equatable & Sendable>(
dynamicMember keyPath: _WritableKeyPath<State, BindingState<Value>>
dynamicMember keyPath: _SendableWritableKeyPath<State, BindingState<Value>>
) -> BindingViewState<Value> {
BindingViewState(
binding: ViewStore(self.store, observe: { $0[keyPath: keyPath].wrappedValue })
Expand Down
2 changes: 1 addition & 1 deletion Sources/ComposableArchitecture/TestStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1918,7 +1918,7 @@ extension TestStore where State: Equatable {
@_disfavoredOverload
@available(iOS 16, macOS 13, tvOS 16, watchOS 9, *)
public func receive<Value: Equatable & Sendable>(
_ actionCase: _CaseKeyPath<Action, Value>,
_ actionCase: _SendableCaseKeyPath<Action, Value>,
_ value: Value,
timeout duration: Duration,
assert updateStateToExpectedResult: ((_ state: inout State) throws -> Void)? = nil,
Expand Down
2 changes: 1 addition & 1 deletion Tests/ComposableArchitectureTests/AppStorageTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ final class AppStorageTests: XCTestCase {
await fulfillment(of: [perceptionExpectation, publisherExpectation], timeout: 1)
}

func testUpdateStoreFromBackgroundThread_KeyPath() async throws {
func testUpdateStoreFromBackgroundThread_SendableKeyPath() async throws {
@Dependency(\.defaultAppStorage) var store
@Shared(.appStorage(\.count)) var count = 0

Expand Down
1 change: 1 addition & 0 deletions Tests/ComposableArchitectureTests/EffectTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ final class EffectTests: BaseTCATestCase {
await withMainSerialExecutor {
let values = LockIsolated<[Int]>([])


let effect = Effect<Int>.concatenate(
.publisher { Just(1).delay(for: 1, scheduler: self.mainQueue) }
)
Expand Down

0 comments on commit 2d0590b

Please sign in to comment.