diff --git a/kotlinx-coroutines-core/common/src/flow/SharingStarted.kt b/kotlinx-coroutines-core/common/src/flow/SharingStarted.kt index b9b73603c4..e1f2051e60 100644 --- a/kotlinx-coroutines-core/common/src/flow/SharingStarted.kt +++ b/kotlinx-coroutines-core/common/src/flow/SharingStarted.kt @@ -1,6 +1,7 @@ package kotlinx.coroutines.flow import kotlinx.coroutines.* +import kotlinx.coroutines.flow.internal.unsafeFlow import kotlinx.coroutines.internal.IgnoreJreRequirement import kotlin.time.* @@ -146,7 +147,7 @@ private class StartedEagerly : SharingStarted { } private class StartedLazily : SharingStarted { - override fun command(subscriptionCount: StateFlow): Flow = flow { + override fun command(subscriptionCount: StateFlow): Flow = unsafeFlow { var started = false subscriptionCount.collect { count -> if (count > 0 && !started) {