FIR checker: report CAPTURED_VAL_INITIALIZATION

This commit is contained in:
Jinseong Jeon
2021-05-11 15:41:56 -07:00
committed by TeamCityServer
parent d38effcbbe
commit f0f1e2d945
20 changed files with 158 additions and 31 deletions
@@ -36,7 +36,7 @@ fun branchingIndetermineFlow(a: Any?) {
fun nonAnonymousLambdas() {
val x: Int
val initializer = { x = 42 }
val initializer = { <!CAPTURED_VAL_INITIALIZATION!>x<!> = 42 }
myRun(initializer)
<!UNINITIALIZED_VARIABLE!>x<!>.inc()
}
@@ -55,7 +55,7 @@ fun funWithUnknownInvocations(block: () -> Unit) = block()
fun nestedIndefiniteAssignment() {
val x: Int
// Captured val initialization reported, because we don't know anything about funWithUnknownInvocations
funWithUnknownInvocations { myRun { x = 42 } }
funWithUnknownInvocations { myRun { <!CAPTURED_VAL_INITIALIZATION!>x<!> = 42 } }
<!UNINITIALIZED_VARIABLE!>x<!>.inc()
}
@@ -65,4 +65,4 @@ class InitializationForbiddenInNonInitSection {
fun setup() {
myRun { x = 42 }
}
}
}
@@ -46,6 +46,6 @@ fun funWithUnknownInvocations(block: () -> Unit) = block()
fun nestedIndefiniteAssignment() {
val x: Int
funWithUnknownInvocations { myRun { x = 42 } }
funWithUnknownInvocations { myRun { <!CAPTURED_VAL_INITIALIZATION!>x<!> = 42 } }
<!UNINITIALIZED_VARIABLE!>x<!>.inc()
}
}