JVM: add tests fixed by the last two commits

One was broken on JVM, the other on JVM_IR.
This commit is contained in:
pyos
2020-04-03 15:04:05 +02:00
committed by Ilmir Usmanov
parent 829343cf6f
commit 516692008f
6 changed files with 132 additions and 0 deletions
@@ -0,0 +1,37 @@
// WITH_RUNTIME
// WITH_REFLECT
// WITH_COROUTINES
// TARGET_BACKEND: JVM
// NO_CHECK_LAMBDA_INLINING
// FILE: inlined.kt
package test
interface SuspendRunnable<R> {
suspend fun run(): R
}
inline fun makeKAdder(crossinline x: suspend () -> String) = object : SuspendRunnable<String> {
override suspend fun run() = run { x() } + "K"
}
// FILE: box.kt
import test.*
import helpers.*
import kotlin.reflect.*
import kotlin.reflect.jvm.*
import kotlin.coroutines.*
import kotlin.coroutines.intrinsics.*
suspend fun getO(): String = suspendCoroutineUninterceptedOrReturn { cont ->
cont.resume("O")
COROUTINE_SUSPENDED
}
var result = ""
fun box(): String {
suspend {
result = ((::makeKAdder as KFunction<*>).javaMethod!!.invoke(null, ::getO) as SuspendRunnable<String>).run()
}.startCoroutine(EmptyContinuation)
return result
}