diff --git a/kotlinx-coroutines-core/common/src/flow/operators/Zip.kt b/kotlinx-coroutines-core/common/src/flow/operators/Zip.kt index ba4f0520a5..ebc1dcd9d8 100644 --- a/kotlinx-coroutines-core/common/src/flow/operators/Zip.kt +++ b/kotlinx-coroutines-core/common/src/flow/operators/Zip.kt @@ -106,7 +106,12 @@ public fun combineTransform( flow: Flow, flow2: Flow, @BuilderInference transform: suspend FlowCollector.(a: T1, b: T2) -> Unit -): Flow = combineTransform(flow, flow2, transform) +): Flow = combineTransform(flow, flow2) { args: Array<*> -> + transform( + args[0] as T1, + args[1] as T2 + ) +} /** * Returns a [Flow] whose values are generated with [transform] function by combining diff --git a/kotlinx-coroutines-core/common/test/flow/operators/CombineTest.kt b/kotlinx-coroutines-core/common/test/flow/operators/CombineTest.kt index 637cb3d697..a619355b68 100644 --- a/kotlinx-coroutines-core/common/test/flow/operators/CombineTest.kt +++ b/kotlinx-coroutines-core/common/test/flow/operators/CombineTest.kt @@ -260,6 +260,11 @@ class CombineIterableTest : CombineTestBase() { combineOriginal(listOf(this, other)) { args -> transform(args[0] as T1, args[1] as T2) } } +class CombineTransformAdapterTest : CombineTestBase() { + override fun Flow.combineLatest(other: Flow, transform: suspend (T1, T2) -> R): Flow = + combineTransformOriginal(flow = this, flow2 = other) { a1, a2 -> emit(transform(a1, a2)) } +} + class CombineTransformVarargAdapterTest : CombineTestBase() { override fun Flow.combineLatest(other: Flow, transform: suspend (T1, T2) -> R): Flow = combineTransformOriginal(this, other) { args: Array -> emit(transform(args[0] as T1, args[1] as T2)) }