Skip to content

Commit 31b0755

Browse files
committed
Revert "Deprecate non-writable scopes"
This reverts commit 95570eb.
1 parent 95570eb commit 31b0755

File tree

4 files changed

+4
-393
lines changed

4 files changed

+4
-393
lines changed

Sources/ComposableArchitecture/Observation/IdentifiedArray+Observation.swift

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -67,34 +67,7 @@ extension Store where State: ObservableState {
6767
/// - filePath: The filePath.
6868
/// - line: The line.
6969
/// - Returns: An collection of stores of child state.
70-
public func scope<ElementID, ElementState, ElementAction>(
71-
state: WritableKeyPath<State, IdentifiedArray<ElementID, ElementState>>,
72-
action: CaseKeyPath<Action, IdentifiedAction<ElementID, ElementAction>>,
73-
fileID: StaticString = #fileID,
74-
filePath: StaticString = #filePath,
75-
line: UInt = #line,
76-
column: UInt = #column
77-
) -> some RandomAccessCollection<Store<ElementState, ElementAction>> {
78-
if !core.canStoreCacheChildren {
79-
reportIssue(
80-
uncachedStoreWarning(self),
81-
fileID: fileID,
82-
filePath: filePath,
83-
line: line,
84-
column: column
85-
)
86-
}
87-
return _StoreCollection(self.scope(state: state, action: action))
88-
}
89-
90-
@available(
91-
*,
92-
deprecated,
93-
message: """
94-
Scoped 'state' must be a writable key path. For more information on this change, see the migration guide: https://pointfreeco.github.io/swift-composable-architecture/main/documentation/composablearchitecture/migratingto1.19#TODO
95-
"""
96-
)
97-
@_documentation(visibility: private)
70+
@_disfavoredOverload
9871
public func scope<ElementID, ElementState, ElementAction>(
9972
state: KeyPath<State, IdentifiedArray<ElementID, ElementState>>,
10073
action: CaseKeyPath<Action, IdentifiedAction<ElementID, ElementAction>>,
@@ -123,7 +96,7 @@ public struct _StoreCollection<ID: Hashable & Sendable, State, Action>: RandomAc
12396
#if swift(<5.10)
12497
@MainActor(unsafe)
12598
#else
126-
@preconcurrency @MainActor
99+
@preconcurrency@MainActor
127100
#endif
128101
fileprivate init(_ store: Store<IdentifiedArray<ID, State>, IdentifiedAction<ID, Action>>) {
129102
self.store = store
@@ -162,8 +135,8 @@ public struct _StoreCollection<ID: Hashable & Sendable, State, Action>: RandomAc
162135
IfLetCore(
163136
base: core,
164137
cachedState: self.data[position],
165-
stateKeyPath: \.[id: elementID],
166-
actionKeyPath: \.[id: elementID]
138+
stateKeyPath: \.[id:elementID],
139+
actionKeyPath: \.[id:elementID]
167140
)
168141
}
169142
return self.store.scope(id: scopeID, childCore: open(self.store.core))

Sources/ComposableArchitecture/Observation/NavigationStack+Observation.swift

Lines changed: 0 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -61,27 +61,6 @@ extension Binding {
6161
#else
6262
@MainActor(unsafe)
6363
#endif
64-
public func scope<State: ObservableState, Action, ElementState, ElementAction>(
65-
state: WritableKeyPath<State, StackState<ElementState>>,
66-
action: CaseKeyPath<Action, StackAction<ElementState, ElementAction>>
67-
) -> Binding<Store<StackState<ElementState>, StackAction<ElementState, ElementAction>>>
68-
where Value == Store<State, Action> {
69-
self[state: state, action: action]
70-
}
71-
72-
@available(
73-
*,
74-
deprecated,
75-
message: """
76-
Scoped 'state' must be a writable key path. For more information on this change, see the migration guide: https://pointfreeco.github.io/swift-composable-architecture/main/documentation/composablearchitecture/migratingto1.19#TODO
77-
"""
78-
)
79-
@_documentation(visibility: private)
80-
#if swift(>=5.10)
81-
@preconcurrency@MainActor
82-
#else
83-
@MainActor(unsafe)
84-
#endif
8564
public func scope<State: ObservableState, Action, ElementState, ElementAction>(
8665
state: KeyPath<State, StackState<ElementState>>,
8766
action: CaseKeyPath<Action, StackAction<ElementState, ElementAction>>
@@ -102,27 +81,6 @@ extension SwiftUI.Bindable {
10281
#else
10382
@MainActor(unsafe)
10483
#endif
105-
public func scope<State: ObservableState, Action, ElementState, ElementAction>(
106-
state: WritableKeyPath<State, StackState<ElementState>>,
107-
action: CaseKeyPath<Action, StackAction<ElementState, ElementAction>>
108-
) -> Binding<Store<StackState<ElementState>, StackAction<ElementState, ElementAction>>>
109-
where Value == Store<State, Action> {
110-
self[state: state, action: action]
111-
}
112-
113-
@available(
114-
*,
115-
deprecated,
116-
message: """
117-
Scoped 'state' must be a writable key path. For more information on this change, see the migration guide: https://pointfreeco.github.io/swift-composable-architecture/main/documentation/composablearchitecture/migratingto1.19#TODO
118-
"""
119-
)
120-
@_documentation(visibility: private)
121-
#if swift(>=5.10)
122-
@preconcurrency@MainActor
123-
#else
124-
@MainActor(unsafe)
125-
#endif
12684
public func scope<State: ObservableState, Action, ElementState, ElementAction>(
12785
state: KeyPath<State, StackState<ElementState>>,
12886
action: CaseKeyPath<Action, StackAction<ElementState, ElementAction>>
@@ -141,22 +99,6 @@ extension Perception.Bindable {
14199
///
142100
/// See ``SwiftUI/Binding/scope(state:action:fileID:filePath:line:column:)`` defined on `Binding` for more
143101
/// information.
144-
public func scope<State: ObservableState, Action, ElementState, ElementAction>(
145-
state: WritableKeyPath<State, StackState<ElementState>>,
146-
action: CaseKeyPath<Action, StackAction<ElementState, ElementAction>>
147-
) -> Binding<Store<StackState<ElementState>, StackAction<ElementState, ElementAction>>>
148-
where Value == Store<State, Action> {
149-
self[state: state, action: action]
150-
}
151-
152-
@available(
153-
*,
154-
deprecated,
155-
message: """
156-
Scoped 'state' must be a writable key path. For more information on this change, see the migration guide: https://pointfreeco.github.io/swift-composable-architecture/main/documentation/composablearchitecture/migratingto1.19#TODO
157-
"""
158-
)
159-
@_documentation(visibility: private)
160102
public func scope<State: ObservableState, Action, ElementState, ElementAction>(
161103
state: KeyPath<State, StackState<ElementState>>,
162104
action: CaseKeyPath<Action, StackAction<ElementState, ElementAction>>
@@ -176,27 +118,6 @@ extension UIBindable {
176118
#else
177119
@MainActor(unsafe)
178120
#endif
179-
public func scope<State: ObservableState, Action, ElementState, ElementAction>(
180-
state: WritableKeyPath<State, StackState<ElementState>>,
181-
action: CaseKeyPath<Action, StackAction<ElementState, ElementAction>>
182-
) -> UIBinding<Store<StackState<ElementState>, StackAction<ElementState, ElementAction>>>
183-
where Value == Store<State, Action> {
184-
self[state: state, action: action]
185-
}
186-
187-
@available(
188-
*,
189-
deprecated,
190-
message: """
191-
Scoped 'state' must be a writable key path. For more information on this change, see the migration guide: https://pointfreeco.github.io/swift-composable-architecture/main/documentation/composablearchitecture/migratingto1.19#TODO
192-
"""
193-
)
194-
@_documentation(visibility: private)
195-
#if swift(>=5.10)
196-
@preconcurrency@MainActor
197-
#else
198-
@MainActor(unsafe)
199-
#endif
200121
public func scope<State: ObservableState, Action, ElementState, ElementAction>(
201122
state: KeyPath<State, StackState<ElementState>>,
202123
action: CaseKeyPath<Action, StackAction<ElementState, ElementAction>>
@@ -463,24 +384,6 @@ public struct _NavigationLinkStoreContent<State, Label: View>: View {
463384
}
464385

465386
extension Store where State: ObservableState {
466-
fileprivate subscript<ElementState, ElementAction>(
467-
state state: WritableKeyPath<State, StackState<ElementState>>,
468-
action action: CaseKeyPath<Action, StackAction<ElementState, ElementAction>>,
469-
isInViewBody isInViewBody: Bool = _isInPerceptionTracking
470-
) -> Store<StackState<ElementState>, StackAction<ElementState, ElementAction>> {
471-
get {
472-
#if DEBUG && !os(visionOS)
473-
_PerceptionLocals.$isInPerceptionTracking.withValue(isInViewBody) {
474-
self.scope(state: state, action: action)
475-
}
476-
#else
477-
self.scope(state: state, action: action)
478-
#endif
479-
}
480-
set {}
481-
}
482-
483-
@available(*, deprecated)
484387
fileprivate subscript<ElementState, ElementAction>(
485388
state state: KeyPath<State, StackState<ElementState>>,
486389
action action: CaseKeyPath<Action, StackAction<ElementState, ElementAction>>,

0 commit comments

Comments
 (0)