Disable tail call optimization, if the call is inside try block

#KT-21165: Fixed
This commit is contained in:
Ilmir Usmanov
2018-01-09 17:13:19 +03:00
parent 3cfe43f83a
commit 5dbab2f907
9 changed files with 102 additions and 0 deletions
@@ -0,0 +1,37 @@
// WITH_RUNTIME
// WITH_COROUTINES
import helpers.*
import kotlin.coroutines.experimental.*
import kotlin.coroutines.experimental.intrinsics.*
val postponedActions = ArrayList<() -> Unit>()
suspend fun suspendWithException(): String = suspendCoroutine { x ->
postponedActions.add {
x.resumeWithException(Exception("OK"))
}
}
suspend fun catchException(): String {
try {
return suspendWithException()
}
catch(e: Exception) {
return e.message!!
}
}
fun run(c: suspend () -> String): String {
var res: String = "FAIL 0"
c.startCoroutine(handleResultContinuation {
res = it
})
postponedActions[0]()
return res
}
fun box(): String {
return run {
catchException()
}
}