FIR checker: report CAPTURED_VAL_INITIALIZATION
This commit is contained in:
committed by
TeamCityServer
parent
d38effcbbe
commit
f0f1e2d945
+3
-3
@@ -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 }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user