185b5013fe
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
36 lines
541 B
Kotlin
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"
|
|
} |