Files
kotlin-fork/compiler/testData/codegen/box/finally/nestedFinallyAndNonFinallyTry2.kt
T
Mikhael Bogdanov c335015c05 Generate proper exception table
Don't forget to split nested try blocks without finally block
 on generating finally blocks from outer ones.

 #KT-31923 InProgress
2019-12-12 13:33:39 +01:00

34 lines
807 B
Kotlin
Vendored

// !LANGUAGE: +ProperFinally
var result = ""
fun test() {
try {
try {
try {
result += "try"
return
} catch (fail: Throwable) {
result += " catch"
}
} catch (e: Throwable) {
result += " finally_catch"
} finally {
result += " finally 1"
throw RuntimeException("Fail 1")
}
} finally {
result += " finally 2"
throw RuntimeException("Fail 2")
}
}
fun box(): String {
try {
test()
return "fail: expected exception"
} catch (e: RuntimeException) {
if (e.message != "Fail 2") return "wrong exception: ${e.message}"
}
return if (result == "try finally 1 finally 2") "OK" else "fail: $result"
}