[FIR] Run CFA for member properties even if they have initializer
^KT-56678 Fixed ^KT-56682 Fixed
This commit is contained in:
committed by
Space Team
parent
de84cb8038
commit
c87e489dc9
Vendored
+40
@@ -0,0 +1,40 @@
|
||||
// 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<!>)
|
||||
<!INITIALIZATION_BEFORE_DECLARATION!>x<!> = 10
|
||||
}
|
||||
|
||||
val x: Int by delegate()
|
||||
|
||||
init {
|
||||
<!VAL_REASSIGNMENT!>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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user