IC & Coroutines: Unbox inline class parameter of suspend lambda
inside 'create' if 'create' overrides 'create' from BaseContinuationImpl. In other words, unbox the parameter if 'create' accepts only one parameter. #KT-43249 Fixed #KT-43533 Fixed
This commit is contained in:
+26
@@ -0,0 +1,26 @@
|
||||
// WITH_RUNTIME
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
|
||||
import kotlin.coroutines.*
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(Continuation(EmptyCoroutineContext) {
|
||||
it.getOrThrow()
|
||||
})
|
||||
}
|
||||
|
||||
inline class IC(val s: String)
|
||||
|
||||
suspend fun <T> List<T>.onEach(c: suspend (T) -> Unit) {
|
||||
for (e in this) {
|
||||
c(e)
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var res = ""
|
||||
builder {
|
||||
listOf(IC("O"), IC("K")).onEach { res += it.s }
|
||||
}
|
||||
return res
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
// WITH_RUNTIME
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
|
||||
import kotlin.coroutines.*
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(Continuation(EmptyCoroutineContext) {
|
||||
it.getOrThrow()
|
||||
})
|
||||
}
|
||||
|
||||
inline class IC(val s: String)
|
||||
|
||||
suspend fun <T> List<T>.onEach(c: suspend (T) -> Unit) {
|
||||
for (e in this) {
|
||||
c(e)
|
||||
}
|
||||
}
|
||||
|
||||
var c: Continuation<Any>? = null
|
||||
|
||||
fun box(): String {
|
||||
var res = ""
|
||||
builder {
|
||||
listOf(IC("O"), IC("K")).onEach { res += suspendCoroutine<String> { cont ->
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
c = cont as Continuation<Any>
|
||||
}}
|
||||
}
|
||||
c?.resume("O")
|
||||
c?.resume("K")
|
||||
return res
|
||||
}
|
||||
Vendored
+35
@@ -0,0 +1,35 @@
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
|
||||
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)
|
||||
|
||||
suspend fun <T> List<T>.onEach(c: suspend (T) -> Unit) {
|
||||
for (e in this) {
|
||||
c(e)
|
||||
}
|
||||
}
|
||||
|
||||
var c: Continuation<Any>? = null
|
||||
|
||||
fun box(): String {
|
||||
builder {
|
||||
listOf(IC("O"), IC("K")).onEach { suspendCoroutine<String> { cont ->
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
c = cont as Continuation<Any>
|
||||
}}
|
||||
}
|
||||
c?.resumeWithException(IllegalStateException("OK"))
|
||||
return result
|
||||
}
|
||||
Reference in New Issue
Block a user