Disable tail call optimization, if the call is inside try block
#KT-21165: Fixed
This commit is contained in:
@@ -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()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
suspend fun catchException(): String {
|
||||
try {
|
||||
return suspendWithException()
|
||||
}
|
||||
catch(e: Exception) {
|
||||
return e.message!!
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun suspendWithException(): String = TODO()
|
||||
@@ -0,0 +1,17 @@
|
||||
@kotlin.Metadata
|
||||
final class TryCatchTailCallKt$catchException$1 {
|
||||
synthetic field data: java.lang.Object
|
||||
synthetic field exception: java.lang.Throwable
|
||||
inner class TryCatchTailCallKt$catchException$1
|
||||
method <init>(p0: kotlin.coroutines.experimental.Continuation): void
|
||||
public final @org.jetbrains.annotations.Nullable method doResume(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Throwable): java.lang.Object
|
||||
synthetic final method getLabel(): int
|
||||
synthetic final method setLabel(p0: int): void
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class TryCatchTailCallKt {
|
||||
inner class TryCatchTailCallKt$catchException$1
|
||||
public final static @org.jetbrains.annotations.Nullable method catchException(@org.jetbrains.annotations.Nullable p0: java.lang.Object): java.lang.Object
|
||||
public final static @org.jetbrains.annotations.Nullable method suspendWithException(@org.jetbrains.annotations.Nullable p0: java.lang.Object): java.lang.Object
|
||||
}
|
||||
Reference in New Issue
Block a user