mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-08 15:53:19 +00:00
Support lateinit local vars in redundant null check elimination
Lateinit local vars are guaranteed to be non-null after store. So we mark such stores as storing non-null value (could be useful for some other constructs, too), and optimize null checks accordingly.
This commit is contained in:
12
compiler/testData/codegen/bytecodeText/nullCheckOptimization/localLateinit/initialized.kt
vendored
Normal file
12
compiler/testData/codegen/bytecodeText/nullCheckOptimization/localLateinit/initialized.kt
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
// LANGUAGE_VERSION: 1.2
|
||||
|
||||
fun test() {
|
||||
lateinit var z: String
|
||||
run {
|
||||
z = ""
|
||||
}
|
||||
println(z)
|
||||
}
|
||||
|
||||
// 0 IFNULL
|
||||
// 0 IFNONNULL
|
||||
Reference in New Issue
Block a user