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:
Mikhael Bogdanov
2013-08-16 13:03:14 +04:00
parent d0f042ba93
commit 185b5013fe
7 changed files with 284 additions and 30 deletions
@@ -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"
}