Files
kotlin/compiler/testData/codegen/bytecodeText/nullCheckOptimization/localLateinit/checkedAlways.kt
Alexander Udalov 5b58eb8491 Remove LANGUAGE_VERSION from non-coroutine codegen tests
Most of these tests used this directive as a way to opt in to a new
language feature, and most of those features are already stable for a
long time, so no opt-in is needed. Some other tests used the directive
to opt out from a language feature, replace those by the `LANGUAGE`
directive. One test used the directive to test behavior that actually
depended on the API version; use `API_VERSION` directive there instead.
2018-12-20 12:53:23 +01:00

25 lines
523 B
Kotlin
Vendored

fun almostAlwaysTrue() = true
fun runNoInline(f: () -> Unit) = f()
fun test() {
lateinit var z: String
runNoInline {
// NB this code can be executed in a different thread multiple times, each time with different results.
// So, 'z' can be initialized at any moment, and should be checked on every read.
if (almostAlwaysTrue()) {
z = ""
}
}
println(z)
println(z)
println(z)
}
// 0 IFNULL
// 3 IFNONNULL
// 3 throwUninitializedPropertyAccessException