JVM IR: Do not unbox Results in suspend lambda invoke methods (KT-46813)
This commit is contained in:
committed by
Ilmir Usmanov
parent
ff3f3d2f9b
commit
984e912f8d
@@ -0,0 +1,17 @@
|
||||
// WITH_RUNTIME
|
||||
import kotlin.coroutines.*
|
||||
|
||||
fun <T, R> T.map(transform: suspend (T) -> R): suspend () -> R =
|
||||
{ transform(this) }
|
||||
|
||||
fun runs(f: suspend () -> String?): String {
|
||||
var result: String? = ""
|
||||
f.startCoroutine(Continuation(EmptyCoroutineContext) { result = it.getOrThrow() })
|
||||
return result ?: "Fail"
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return runs {
|
||||
Result.success("OK").map<Result<String>, String?> { it.getOrNull() }()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user