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:
+2
-2
@@ -41,8 +41,8 @@ class case_5 {
|
||||
<!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>var value_5: Int<!>
|
||||
init {
|
||||
funWithAtMostOnceCallsInPlace { value_1 = 1 }
|
||||
funWithUnknownCallsInPlace { value_2 = 1 }
|
||||
funWithAtLeastOnceCallsInPlace { value_3 = 1 }
|
||||
funWithUnknownCallsInPlace { <!VAL_REASSIGNMENT!>value_2<!> = 1 }
|
||||
funWithAtLeastOnceCallsInPlace { <!VAL_REASSIGNMENT!>value_3<!> = 1 }
|
||||
funWithAtMostOnceCallsInPlace { value_4 = 2 }
|
||||
funWithUnknownCallsInPlace { value_5 = 3 }
|
||||
}
|
||||
|
||||
+2
-2
@@ -39,7 +39,7 @@ class case_3(value_1: Any?) {
|
||||
init {
|
||||
if (value_1 is String) {
|
||||
funWithUnknownCallsInPlace { value_2 = 0 }
|
||||
value_2.div(10)
|
||||
<!UNINITIALIZED_VARIABLE!>value_2<!>.div(10)
|
||||
} else if (value_1 == null) {
|
||||
funWithAtLeastOnceCallsInPlace { value_2 = 1 }
|
||||
value_2.div(10)
|
||||
@@ -47,7 +47,7 @@ class case_3(value_1: Any?) {
|
||||
value_2 = 2
|
||||
}
|
||||
|
||||
value_2.div(10)
|
||||
<!UNINITIALIZED_VARIABLE!>value_2<!>.div(10)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ fun case_4() {
|
||||
fun case_5() {
|
||||
val value_1: Int
|
||||
val o = object {
|
||||
fun l() { value_1 = 10 }
|
||||
fun l() { <!CAPTURED_VAL_INITIALIZATION!>value_1<!> = 10 }
|
||||
}
|
||||
funWithExactlyOnceCallsInPlace(o::l)
|
||||
<!UNINITIALIZED_VARIABLE!>value_1<!>.inc()
|
||||
|
||||
Reference in New Issue
Block a user