Files
kotlin-fork/compiler/testData/diagnostics/tests/secondaryConstructors/propertyInitializationWithPrimary.fir.kt
T
pyos 99e51f6940 FIR: check assignments and references to members in constructors
I.e. emit VAL_REASSIGNMENT on repeated assignments to `this.something`,
UNINITIALIZED_VARIABLE on reads of it before any assignment if there is
no initializer, and CAPTURED_MEMBER_VAL_INITIALIZATION on assignments
inside non-called-in-place functions and named classes.

^KT-55528 Fixed
2023-01-26 13:12:13 +00:00

34 lines
546 B
Kotlin
Vendored

// !DIAGNOSTICS: -UNUSED_PARAMETER
class A(val w: Char) {
val x: Int
var y: Int
val z: Int
val v = -1
<!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>val uninitialized: Int<!>
val overinitialized: Int
constructor(): this('a') {
y = 1
<!VAL_REASSIGNMENT!>overinitialized<!> = 2
uninitialized = 3
}
// anonymous
init {
x = 4
z = 5
overinitialized = 6
}
constructor(a: Int): this('b') {
y = 7
}
// anonymous
init {
y = 8
}
}