Fix derive state read during recomposition
Uses `DerivedState<*>.currentValue` as opposed to `DerivedState<*>.value` to read current derived state value without recording a read.
Without this change, composition was recording read of `DerivedState` in random scopes (depending on the current `currentRecomposeScope` inside `recomposeToGroupEnd` loop), sometimes causing infinite recompositions.
Fixes: 232890413
Test: N/A, couldn't reproduce inside test environment
Change-Id: I34dd87dfc15e769753c6cb132c6186a4dff9ce80
diff --git a/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/RecomposeScopeImpl.kt b/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/RecomposeScopeImpl.kt
index d050ce0..e2b0c73 100644
--- a/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/RecomposeScopeImpl.kt
+++ b/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/RecomposeScopeImpl.kt
@@ -240,7 +240,8 @@
if (
instances.isNotEmpty() &&
instances.all { instance ->
- instance is DerivedState<*> && trackedDependencies[instance] == instance.value
+ instance is DerivedState<*> &&
+ trackedDependencies[instance] == instance.currentValue
}
)
return false