JVM backend test for local returns

This commit is contained in:
Andrey Breslav
2013-08-21 18:05:36 +04:00
parent 08625a6b2f
commit aa99c29d8d
2 changed files with 24 additions and 0 deletions
@@ -0,0 +1,19 @@
fun box(): String {
val a = 1
val explicitlyReturned = run1 @f{(): String ->
if (a > 0)
return@f "OK"
else "Fail 1"
}
if (explicitlyReturned != "OK") return explicitlyReturned
val implicitlyReturned = run1 @f{(): String ->
if (a < 0)
return@f "Fail 2"
else "OK"
}
if (implicitlyReturned != "OK") return implicitlyReturned
return "OK"
}
fun run1<T>(f: () -> T): T { return f() }