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,35 @@
fun test1(): String {
var r = ""
for (i in 1..2) {
try {
r += "O"
continue
} finally {
r += "K"
break
}
}
return r
}
fun test2(): String {
var r = ""
for (i in 1..2) {
try {
r += "O"
break
} finally {
r += "K"
continue
}
}
return r
}
fun box(): String {
if (test1() != "OK") return "fail1: ${test1()}"
if (test2() != "OKOK") return "fail2: ${test2()}"
return "OK"
}