Files
kotlin-fork/compiler/testData/codegen/box/finally/kt3894.kt
T
Mikhael Bogdanov 185b5013fe Properly process nested try and loop blocks
KT-3894: Loops and finally: finally block executed twice when break and return exists in try/finally block
KT-3874: Compilation error on try catch block contains break and continue
KT-3869: Loops and finally: outer finally block not run

 #KT-3869 Fixed
 #KT-3894 Fixed
 #KT-3874 Fixed
2013-08-19 16:06:56 +04:00

36 lines
541 B
Kotlin

class MyString {
var s = ""
fun plus(x : String) : MyString {
s += x
return this
}
fun toString(): String {
return s
}
}
fun test1() : MyString {
var r = MyString()
while (true) {
try {
r + "Try"
if (true) {
r + "Break"
break
}
} finally {
return r + "Finally"
}
}
}
fun box(): String {
if (test1().toString() != "TryBreakFinally") return "fail1: ${test1().toString()}"
return "OK"
}