Use of uninitialized variables in lambdas / object literals / local functions is forbidden now #KT-4475 Fixed
Local declarations CFA: variable initialization information before them is now taken into account
This commit is contained in:
+4
-4
@@ -3,9 +3,9 @@ package o
|
||||
|
||||
class TestFunctionLiteral {
|
||||
val sum: (Int) -> Int = { x: Int ->
|
||||
sum(x - 1) + x
|
||||
<!UNINITIALIZED_VARIABLE!>sum<!>(x - 1) + x
|
||||
}
|
||||
val foo: () -> Unit = l@ ({ foo() })
|
||||
val foo: () -> Unit = l@ ({ <!UNINITIALIZED_VARIABLE!>foo<!>() })
|
||||
}
|
||||
|
||||
open class A(val a: A)
|
||||
@@ -16,14 +16,14 @@ class TestObjectLiteral {
|
||||
val x = <!UNINITIALIZED_VARIABLE!>obj<!>
|
||||
}
|
||||
fun foo() {
|
||||
val y = obj
|
||||
val y = <!UNINITIALIZED_VARIABLE!>obj<!>
|
||||
}
|
||||
}
|
||||
val obj1: A = l@ ( object: A(<!UNINITIALIZED_VARIABLE!>obj1<!>) {
|
||||
init {
|
||||
val x = <!UNINITIALIZED_VARIABLE!>obj1<!>
|
||||
}
|
||||
fun foo() = obj1
|
||||
fun foo() = <!UNINITIALIZED_VARIABLE!>obj1<!>
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user