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:
+20
@@ -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"
|
||||
}
|
||||
+20
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user