FIR checker: report CAPTURED_VAL_INITIALIZATION
This commit is contained in:
committed by
TeamCityServer
parent
d38effcbbe
commit
f0f1e2d945
+4
-4
@@ -17,14 +17,14 @@ fun foo() {
|
||||
fun bar() {
|
||||
val x: Int
|
||||
exec {
|
||||
x = 13
|
||||
<!CAPTURED_VAL_INITIALIZATION!>x<!> = 13
|
||||
}
|
||||
}
|
||||
|
||||
fun bar2() {
|
||||
val x: Int
|
||||
fun foo() {
|
||||
x = 3
|
||||
<!CAPTURED_VAL_INITIALIZATION!>x<!> = 3
|
||||
}
|
||||
foo()
|
||||
}
|
||||
@@ -60,7 +60,7 @@ class Your {
|
||||
val y = if (true) {
|
||||
val xx: Int
|
||||
exec {
|
||||
xx = 42
|
||||
<!CAPTURED_VAL_INITIALIZATION!>xx<!> = 42
|
||||
}
|
||||
24
|
||||
}
|
||||
@@ -70,7 +70,7 @@ class Your {
|
||||
val z = if (true) {
|
||||
val xx: Int
|
||||
exec {
|
||||
xx = 24
|
||||
<!CAPTURED_VAL_INITIALIZATION!>xx<!> = 24
|
||||
}
|
||||
42
|
||||
}
|
||||
|
||||
+1
-1
@@ -59,7 +59,7 @@ fun gau() {
|
||||
object: Any() {
|
||||
init {
|
||||
// Error!
|
||||
y = ""
|
||||
<!CAPTURED_VAL_INITIALIZATION!>y<!> = ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+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