Make CHECKCAST Object not break tail-call optimization
Since CHECKCAST Object does nothing for return value of suspend function - the function returns references only, this is safe. #KT-49157 Fixed
This commit is contained in:
+32
@@ -0,0 +1,32 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// FULL_JDK
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
// CHECK_TAIL_CALL_OPTIMIZATION
|
||||
import helpers.*
|
||||
import kotlin.coroutines.*
|
||||
import kotlin.coroutines.intrinsics.*
|
||||
|
||||
suspend fun awaitInternal(): Any? = TailCallOptimizationChecker.saveStackTrace()
|
||||
|
||||
interface Deferred<out T> {
|
||||
suspend fun await(): T
|
||||
}
|
||||
|
||||
open class DeferredCoroutine<T> : Deferred<T> {
|
||||
override suspend fun await(): T = awaitInternal() as T
|
||||
}
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(Continuation(EmptyCoroutineContext) {
|
||||
it.getOrThrow()
|
||||
})
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
builder {
|
||||
DeferredCoroutine<String>().await()
|
||||
}
|
||||
TailCallOptimizationChecker.checkNoStateMachineIn("await\$suspendImpl")
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user