IC & Coroutines: Unbox inline classes of suspend lambdas
inside 'invoke' if 'create' does not override 'create' from BaseContinuationImpl. In other words, when suspend lambda accepts more than one parameter (including receiver). Do that only if we do not generate bridge 'invoke' method, since inline classes are unboxed in the bridge. Use mangled name for 'create' function in this case inside 'invoke'. #KT-43249 In progress #KT-39847 Fixed #KT-38937 Fixed
This commit is contained in:
+22
@@ -0,0 +1,22 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
import kotlin.coroutines.*
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(Continuation(EmptyCoroutineContext) {
|
||||
it.getOrThrow()
|
||||
})
|
||||
}
|
||||
|
||||
inline class IC(val s: String)
|
||||
|
||||
fun box(): String {
|
||||
var res = "FAIL"
|
||||
val lambda: suspend (IC, IC) -> String = { a, b ->
|
||||
a.s + b.s
|
||||
}
|
||||
builder {
|
||||
res = lambda(IC("O"), IC("K"))
|
||||
}
|
||||
return res
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
import kotlin.coroutines.*
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(Continuation(EmptyCoroutineContext) {
|
||||
it.getOrThrow()
|
||||
})
|
||||
}
|
||||
|
||||
inline class IC(val s: String)
|
||||
|
||||
var c: Continuation<Any>? = null
|
||||
|
||||
var res = "FAIL"
|
||||
|
||||
fun box(): String {
|
||||
val lambda: suspend (IC, IC) -> String = { _, _ ->
|
||||
suspendCoroutine<String> {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
c = it as Continuation<Any>
|
||||
}
|
||||
}
|
||||
builder {
|
||||
res = lambda(IC("_"), IC("_"))
|
||||
}
|
||||
c?.resume("OK")
|
||||
return res
|
||||
}
|
||||
Vendored
+31
@@ -0,0 +1,31 @@
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
|
||||
import kotlin.coroutines.*
|
||||
import helpers.*
|
||||
|
||||
var result = "FAIL"
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(handleExceptionContinuation {
|
||||
result = it.message!!
|
||||
})
|
||||
}
|
||||
|
||||
inline class IC(val s: String)
|
||||
|
||||
var c: Continuation<Any>? = null
|
||||
|
||||
fun box(): String {
|
||||
val lambda: suspend (IC, IC) -> String = { _, _ ->
|
||||
suspendCoroutine<String> {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
c = it as Continuation<Any>
|
||||
}
|
||||
}
|
||||
builder {
|
||||
lambda(IC("O"), IC("K"))
|
||||
}
|
||||
c?.resumeWithException(IllegalStateException("OK"))
|
||||
return result
|
||||
}
|
||||
Reference in New Issue
Block a user