JVM IR: Do not unbox Results in suspend lambda invoke methods (KT-46813)

This commit is contained in:
Steven Schäfer
2021-05-19 18:50:47 +02:00
committed by Ilmir Usmanov
parent ff3f3d2f9b
commit 984e912f8d
9 changed files with 64 additions and 1 deletions
+17
View File
@@ -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() }()
}
}