mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-14 08:31:35 +00:00
According to KT-21354, this should be a warning in 1.2 and before, and no warning (with changed semantics) in 1.3 and later. NB there are some false positives in this check. #KT-21354 In Progress #KT-21321 In Progress
16 lines
444 B
Kotlin
Vendored
16 lines
444 B
Kotlin
Vendored
// !LANGUAGE: -ProperForInArrayLoopRangeVariableAssignmentSemantic
|
|
// !DIAGNOSTICS: -UNUSED_VALUE
|
|
// SKIP_TXT
|
|
|
|
class Delegate<T>(var v: T) {
|
|
operator fun getValue(thisRef: Any?, kProp: Any?) = v
|
|
operator fun setValue(thisRef: Any?, kProp: Any?, value: T) { v = value }
|
|
}
|
|
|
|
fun testLocalDelegatedProperty() {
|
|
var xs by Delegate(arrayOf("a", "b", "c"))
|
|
for (x in xs) {
|
|
println(x)
|
|
xs = arrayOf("d", "e", "f")
|
|
}
|
|
} |