JS backend: don't translate labels on expression

#KT-7487 Fixed
This commit is contained in:
Zalim Bashorov
2015-04-20 18:28:26 +03:00
parent 1fe93c302a
commit 6e60a31b73
3 changed files with 70 additions and 2 deletions
@@ -0,0 +1,56 @@
// CHECK_LABELS_COUNT: function=test0 count=0
// CHECK_LABELS_COUNT: function=test1 count=0
// CHECK_LABELS_COUNT: function=test2 count=0
// CHECK_LABELS_COUNT: function=test3 count=0
package foo
fun myRun<R>(f: () -> R) = f()
fun test0() {
val a = @aa 1
assertEquals(1, a)
assertEquals(3, @l1 a + @l2 2)
val b = @bb if (true) @t "then block" else @e "else block"
assertEquals("then block", b)
}
fun test1() {
run @label {
return@label false
}
}
fun test2() {
myRun @label {
return@label false
}
}
// KT-7487
public fun test3() {
val f = Foo()
f.iter @label {
return@label false
}
}
class Foo {
inline fun iter(body: ()->Boolean) {
for (i in 0 .. 10) {
if (!body()) break
}
}
}
fun box(): String {
test0()
test1()
test2()
test3()
return "OK"
}