Implemented isInitialized for lateinit properties + tests
This commit is contained in:
@@ -1058,6 +1058,16 @@ task lateinit_localCapturedNotInitialized(type: RunKonanTest) {
|
||||
source = "codegen/lateinit/localCapturedNotInitialized.kt"
|
||||
}
|
||||
|
||||
task lateinit_isInitialized(type: RunKonanTest) {
|
||||
goldValue = "false\ntrue\n"
|
||||
source = "codegen/lateinit/isInitialized.kt"
|
||||
}
|
||||
|
||||
task lateinit_globalIsInitialized(type: RunKonanTest) {
|
||||
goldValue = "false\ntrue\n"
|
||||
source = "codegen/lateinit/globalIsInitialized.kt"
|
||||
}
|
||||
|
||||
task kclass0(type: RunKonanTest) {
|
||||
source = "codegen/kclass/kclass0.kt"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package codegen.lateinit.globalIsInitialized
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
lateinit var s: String
|
||||
|
||||
fun foo() {
|
||||
println(::s.isInitialized)
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
foo()
|
||||
s = "zzz"
|
||||
foo()
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package codegen.lateinit.isInitialized
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
class A {
|
||||
lateinit var s: String
|
||||
|
||||
fun foo() {
|
||||
println(::s.isInitialized)
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
val a = A()
|
||||
a.foo()
|
||||
a.s = "zzz"
|
||||
a.foo()
|
||||
}
|
||||
Reference in New Issue
Block a user