Fix closure's reference to outer closure

#KT-3276 Fixed
This commit is contained in:
Alexander Udalov
2013-01-29 22:15:45 +04:00
parent be349f6229
commit 9007a6214a
7 changed files with 116 additions and 2 deletions
@@ -0,0 +1,13 @@
fun box(): String {
fun rec(n : Int) {
fun x(m : Int) {
if (n > 0) rec(n - 1)
}
x(0)
}
rec(5)
return "OK"
}
@@ -0,0 +1,13 @@
fun box(): String {
fun rec(n : Int) {
fun x(m : Int, k : Int) {
if (n > 0) rec(n - 1 + k)
}
x(0, 0)
}
rec(5)
return "OK"
}
@@ -0,0 +1,17 @@
fun box(): String {
fun foo(x: Int) {
fun bar(y: Int) {
fun baz(z: Int) {
foo(x - 1)
}
baz(y)
}
if (x > 0) bar(x)
}
foo(1)
return "OK"
}
@@ -0,0 +1,16 @@
fun box(): String {
fun foo(x: Int, s: String): String {
fun bar(y: Int) {
fun baz(z: Int, k: Int) {
foo(x - 1 + k, "Fail")
}
baz(y, 0)
}
if (x > 0) bar(x)
return s
}
return foo(1, "OK")
}
@@ -0,0 +1,15 @@
//KT-3276
fun box(): String {
fun rec(n : Int) {
val x = { (m : Int) ->
if (n > 0) rec(n - 1)
}
x(0)
}
rec(5)
return "OK"
}