K2: reproduce KT-58008

This commit is contained in:
Mikhail Glukhikh
2023-04-17 16:40:15 +02:00
committed by Space Team
parent 27b103e2ca
commit 4172ce1018
16 changed files with 266 additions and 0 deletions
@@ -0,0 +1,33 @@
// WITH_STDLIB
// WITH_COROUTINES
// TARGET_BACKEND: JVM_IR
// IGNORE_BACKEND_K2: JVM_IR
// ISSUE: KT-58008
import kotlin.coroutines.*
fun <T> runBlocking(c: suspend () -> T): T {
var res: T? = null
c.startCoroutine(Continuation(EmptyCoroutineContext) {
res = it.getOrThrow()
})
return res!!
}
object Retry {
class Builder<B>(
private val action: suspend () -> B,
) {
fun foo() = runBlocking {
action.invoke()
}
}
fun <W> withExponentialBackoff(action: () -> W): Builder<W> {
return Builder(action)
}
}
fun box(): String {
return Retry.withExponentialBackoff { "OK" }.foo()
}
@@ -0,0 +1,33 @@
// WITH_STDLIB
// WITH_COROUTINES
// TARGET_BACKEND: JVM_IR
// IGNORE_BACKEND_K2: JVM_IR
// ISSUE: KT-58008
import kotlin.coroutines.*
fun <T> runBlocking(c: suspend () -> T): T {
var res: T? = null
c.startCoroutine(Continuation(EmptyCoroutineContext) {
res = it.getOrThrow()
})
return res!!
}
class Owner<C>(val c: C) {
class Builder<B>(
private val action: suspend () -> B,
) {
fun foo() = runBlocking {
action.invoke()
}
}
fun <W> withExponentialBackoff(action: () -> W): Builder<W> {
return Builder(action)
}
}
fun box(): String {
return Owner("").withExponentialBackoff { "OK" }.foo()
}