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
This commit is contained in:
pyos
2023-01-19 12:21:53 +01:00
committed by teamcity
parent 8f45acd71d
commit 99e51f6940
24 changed files with 199 additions and 211 deletions
@@ -1,8 +1,8 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
class A(val w: Int) {
val x: Int
val useUnitialized = x +
y +
val useUnitialized = <!UNINITIALIZED_VARIABLE!>x<!> +
<!UNINITIALIZED_VARIABLE!>y<!> +
v
var y: Int
val v = -1
@@ -11,20 +11,20 @@ class A(val w: Int) {
<!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>val uninitialized: Int<!>
constructor(): this(1) {
x + y + v + uninitialized + w
x + y + v + <!UNINITIALIZED_VARIABLE!>uninitialized<!> + w
}
// anonymous
init {
x + y + v + uninitialized + w
<!UNINITIALIZED_VARIABLE!>x<!> + <!UNINITIALIZED_VARIABLE!>y<!> + v + <!UNINITIALIZED_VARIABLE!>uninitialized<!> + w
x = 1
x + y + v + uninitialized + w
x + <!UNINITIALIZED_VARIABLE!>y<!> + v + <!UNINITIALIZED_VARIABLE!>uninitialized<!> + w
}
// anonymous
init {
x + y + v + uninitialized + w
x + <!UNINITIALIZED_VARIABLE!>y<!> + v + <!UNINITIALIZED_VARIABLE!>uninitialized<!> + w
y = 7
x + y + v + uninitialized + w
x + y + v + <!UNINITIALIZED_VARIABLE!>uninitialized<!> + w
}
}