Skip to content

Commit 4c47829

Browse files
authored
Perception fix for ScopedCore. (#3742)
1 parent af0a2c7 commit 4c47829

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Sources/ComposableArchitecture/Core.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,9 @@ final class ScopedCore<Base: Core, State, Action>: Core {
204204
let base: Base
205205
let stateKeyPath: KeyPath<Base.State, State>
206206
let actionKeyPath: CaseKeyPath<Base.Action, Action>
207+
#if DEBUG
208+
let isInPerceptionTracking = _PerceptionLocals.isInPerceptionTracking
209+
#endif
207210
init(
208211
base: Base,
209212
stateKeyPath: KeyPath<Base.State, State>,
@@ -216,7 +219,13 @@ final class ScopedCore<Base: Core, State, Action>: Core {
216219
@inlinable
217220
@inline(__always)
218221
var state: State {
219-
base.state[keyPath: stateKeyPath]
222+
#if DEBUG
223+
return _PerceptionLocals.$skipPerceptionChecking.withValue(isInPerceptionTracking) {
224+
base.state[keyPath: stateKeyPath]
225+
}
226+
#else
227+
return base.state[keyPath: stateKeyPath]
228+
#endif
220229
}
221230
@inlinable
222231
@inline(__always)

0 commit comments

Comments
 (0)