Skip to content

Commit 002a199

Browse files
committed
work around ambiguous init
1 parent f93b780 commit 002a199

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

Sources/ComposableArchitecture/Reducer/AnyReducer/AnyReducerCompatibility.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ extension Reduce {
4343
_ reducer: AnyReducer<State, Action, Environment>,
4444
environment: Environment
4545
) {
46-
self.init(internal: { state, action in
46+
self = .create { state, action in
4747
reducer.run(&state, action, environment)
48-
})
48+
}
4949
}
5050
}
5151

Sources/ComposableArchitecture/Reducer/Reducers/Observe.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public struct _Observe<Reducers: ReducerProtocol>: ReducerProtocol {
1212
self.init(internal: build)
1313
}
1414

15+
@_disfavoredOverload
1516
@usableFromInline
1617
init(
1718
internal reducers: @escaping (Reducers.State, Reducers.Action) -> Reducers

Sources/ComposableArchitecture/Reducer/Reducers/Reduce.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@ public struct Reduce<State, Action>: ReducerProtocol {
77
let reduce: (inout State, Action) -> Effect<Action, Never>
88

99
@usableFromInline
10-
init(
10+
static func create(
1111
internal reduce: @escaping (inout State, Action) -> Effect<Action, Never>
12-
) {
13-
self.reduce = reduce
12+
) -> Self {
13+
Self(reduce)
1414
}
1515

1616
/// Initializes a reducer with a `reduce` function.
1717
///
1818
/// - Parameter reduce: A function that is called when ``reduce(into:action:)`` is invoked.
1919
@inlinable
2020
public init(_ reduce: @escaping (inout State, Action) -> Effect<Action, Never>) {
21-
self.init(internal: reduce)
21+
self = .create(internal: reduce)
2222
}
2323

2424
/// Type-erases a reducer.
@@ -27,7 +27,7 @@ public struct Reduce<State, Action>: ReducerProtocol {
2727
@inlinable
2828
public init<R: ReducerProtocol>(_ reducer: R)
2929
where R.State == State, R.Action == Action {
30-
self.init(internal: reducer.reduce)
30+
self = .create(internal: reducer.reduce)
3131
}
3232

3333
@inlinable

0 commit comments

Comments
 (0)