JVM_IR: box inline class values returned by suspend inline lambdas

The call site inside the inline function expects them to return a boxed
value, like FunctionN.invoke would.

 #KT-46915 Fixed
This commit is contained in:
pyos
2021-05-25 12:51:51 +02:00
committed by Ilmir Usmanov
parent 117fad2018
commit 33ddeffcfd
13 changed files with 164 additions and 2 deletions
@@ -0,0 +1,20 @@
// WITH_RUNTIME
// WITH_COROUTINES
// IGNORE_BACKEND: JS_IR
// FILE: 1.kt
inline fun <T, R> (suspend () -> T).map(crossinline transform: suspend (T) -> R): suspend () -> R =
{ transform(this()) }
// FILE: 2.kt
import helpers.*
import kotlin.coroutines.*
inline class C(val value: Int)
fun box(): String {
var result = 0
suspend {
result = suspend { C(1) as C? }.map { it }()?.value ?: 2
}.startCoroutine(EmptyContinuation)
return if (result == 1) "OK" else "fail: $result"
}
@@ -0,0 +1,20 @@
// WITH_RUNTIME
// WITH_COROUTINES
// IGNORE_BACKEND: JS_IR
// FILE: 1.kt
inline fun <T, R> (suspend () -> T).map(crossinline transform: suspend (T) -> R): suspend () -> R =
{ transform(this()) }
// FILE: 2.kt
import helpers.*
import kotlin.coroutines.*
inline class C(val value: String)
fun box(): String {
var result = "fail"
suspend {
result = suspend { C("OK") }.map { it }().value
}.startCoroutine(EmptyContinuation)
return result
}