Files
kotlin-fork/compiler/testData/diagnostics/tests/controlFlowAnalysis/delegatedMemberProperyWriteInInit.kt
T
Dmitrii Gridin 9a4a3d1f49 [LL FIR] introduce test with reversed resolve order
^KT-56543

Merge-request: KT-MR-9299
Merged-by: Dmitrii Gridin <dmitry.gridin@jetbrains.com>
2023-03-22 17:34:07 +00:00

42 lines
756 B
Kotlin
Vendored

// IGNORE_REVERSED_RESOLVE
// DIAGNOSTICS: -UNUSED_PARAMETER
import kotlin.reflect.KProperty
interface Delegate<V> {
operator fun getValue(thisRef: Any?, property: KProperty<*>): V = null!!
operator fun setValue(thisRef: Any?, property: KProperty<*>, value: V) {}
}
fun <V> delegate(): Delegate<V> = null!!
fun consume(x: Any?) {}
class A {
init {
consume(<!UNINITIALIZED_VARIABLE!>x<!>)
<!VAL_REASSIGNMENT!>x<!> = 10
}
val x: Int by delegate()
init {
x = 10
consume(x)
}
}
class B {
init {
consume(<!UNINITIALIZED_VARIABLE!>x<!>)
<!INITIALIZATION_BEFORE_DECLARATION!>x<!> = 10
}
var x: Int by delegate()
init {
x = 10
consume(x)
}
}