Files
kotlin-fork/compiler/testData/codegen/box/safeCall/kt1572.kt
T
Alexander Udalov 41a416da60 Move blackBoxFile() testData to box/ directory
Delete all test methods (and empty test classes), since they'll be
auto-generated
2013-01-28 18:20:17 +04:00

24 lines
482 B
Kotlin

//KT-1572 Frontend doesn't mark all vars included in closure as refs.
class A(val t : Int) {}
fun testKt1572() : Boolean {
var a = A(0)
var b = A(3)
val changer = {a = b}
b = A(10) // this change has no effect on changer
changer()
return (a.t == 10)
}
fun testPrimitives() : Boolean {
var a = 0
var b = 3
val changer = {a = b}
b = 10
changer()
return (a == 10)
}
fun box() = if (testKt1572() && testPrimitives()) "OK" else "fail"