effbcdaf70
in OUTERCLASS field. The inliner generates two versions of suspend functions/lambdas in inline functions: with state-machine and without. The former is used to call the function from Java or via reflection and have ordinary name, while the latter is used by inliner and have $$forInline suffix. The inliner throws the state-machine version away, duplicates $$forInline version and then call state-machine generator. If these suspend functions/lambdas are not going to be inlined, $$forInline version is not generated. However, all objects, which are used in these suspend functions/lambdas, have $$forInline version written to OUTERCLASS field. This leads to errors by proguard. Since they are used in both state-machine version and for-inline ones, we can simply remove $$forInline suffix from OUTERCLASS field and this fixes the issue. #KT-31242 Fixed
61 lines
1.6 KiB
Kotlin
Vendored
61 lines
1.6 KiB
Kotlin
Vendored
// IGNORE_BACKEND: JVM_IR
|
|
// TARGET_BACKEND: JVM
|
|
// FILE: flow.kt
|
|
// COMMON_COROUTINES_TEST
|
|
// FULL_JDK
|
|
// WITH_RUNTIME
|
|
// WITH_COROUTINES
|
|
|
|
package flow
|
|
|
|
interface FlowCollector<T> {
|
|
suspend fun emit(value: T)
|
|
}
|
|
|
|
interface Flow<T> {
|
|
suspend fun collect(collector: FlowCollector<T>)
|
|
}
|
|
|
|
public inline fun <T> flow(crossinline block: suspend FlowCollector<T>.() -> Unit) = object : Flow<T> {
|
|
override suspend fun collect(collector: FlowCollector<T>) = collector.block()
|
|
}
|
|
|
|
suspend inline fun <T> Flow<T>.collect(crossinline action: suspend (T) -> Unit): Unit =
|
|
collect(object : FlowCollector<T> {
|
|
override suspend fun emit(value: T) = action(value)
|
|
})
|
|
|
|
public inline fun <T, R> Flow<T>.transform(crossinline transformer: suspend FlowCollector<R>.(value: T) -> Unit): Flow<R> {
|
|
return flow {
|
|
collect { value ->
|
|
transformer(value)
|
|
}
|
|
}
|
|
}
|
|
|
|
public inline fun <T, R> Flow<T>.map(crossinline transformer: suspend (value: T) -> R): Flow<R> = transform { value -> emit(transformer(value)) }
|
|
|
|
inline fun decorate() = suspend {
|
|
flow<Int> {
|
|
emit(1)
|
|
}.map { it + 1 }
|
|
.collect {
|
|
}
|
|
}
|
|
|
|
// FILE: box.kt
|
|
// COMMON_COROUTINES_TEST
|
|
|
|
import flow.*
|
|
|
|
fun box() : String {
|
|
decorate()
|
|
val enclosingMethod = try {
|
|
Class.forName("flow.FlowKt\$decorate\$1\$invokeSuspend\$\$inlined\$map\$1\$1").enclosingMethod
|
|
} catch (ignore: ClassNotFoundException) {
|
|
Class.forName("flow.FlowKt\$decorate\$1\$doResume\$\$inlined\$map\$1\$1").enclosingMethod
|
|
}
|
|
if ("$enclosingMethod".contains("\$\$forInline")) return "$enclosingMethod"
|
|
return "OK"
|
|
}
|