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
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
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"
|
||||
}
|
||||
Reference in New Issue
Block a user