From cae095df9264f3ad3601bc79326a36bcf6c5c240 Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Mon, 4 Aug 2025 16:09:50 -0500 Subject: [PATCH] Perception fix for ScopedCore. --- Sources/ComposableArchitecture/Core.swift | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Sources/ComposableArchitecture/Core.swift b/Sources/ComposableArchitecture/Core.swift index 0c1461c74193..f853848df963 100644 --- a/Sources/ComposableArchitecture/Core.swift +++ b/Sources/ComposableArchitecture/Core.swift @@ -204,6 +204,9 @@ final class ScopedCore: Core { let base: Base let stateKeyPath: KeyPath let actionKeyPath: CaseKeyPath + #if DEBUG + let isInPerceptionTracking = _PerceptionLocals.isInPerceptionTracking + #endif init( base: Base, stateKeyPath: KeyPath, @@ -216,7 +219,13 @@ final class ScopedCore: Core { @inlinable @inline(__always) var state: State { - base.state[keyPath: stateKeyPath] + #if DEBUG + return _PerceptionLocals.$skipPerceptionChecking.withValue(isInPerceptionTracking) { + base.state[keyPath: stateKeyPath] + } + #else + return base.state[keyPath: stateKeyPath] + #endif } @inlinable @inline(__always)