Files
kotlin/compiler/testData/codegen/box/controlStructures/forInArray/forInDelegatedPropertyUpdatedInLoopBody.kt
Dmitry Petrov 3d473f608e Add more tests for for-in-array
#KT-21354 Fixed Target versions 1.2.20
 #KT-21321 Fixed Target versions 1.2.20
2017-12-05 15:45:20 +03:00

17 lines
387 B
Kotlin
Vendored

class Del<T>(var x: T) {
operator fun getValue(thisRef: Any?, kProp: Any) = x
operator fun setValue(thisRef: Any?, kProp: Any, value: T) {
x = value
}
}
fun box(): String {
var xs by Del(intArrayOf(1, 2, 3))
var sum = 0
for (x in xs) {
sum = sum * 10 + x
xs = intArrayOf(4, 5, 6)
}
return if (sum == 123) "OK" else "Fail: $sum"
}