Introduce a separate StackValue class for lateinit local vars
Local lateinit var differs in behavior from a simple local var, and logic that relies of 'instanceof Local' checks assuming that all instances of Local are simple local vars can produce faulty code (as in KT-23260, where a local lateinit var was not explicitly put on stack when passed as an argument to an inline function, thus causing null propagation). #KT-23260 Fixed Target versions 1.2.50
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun box(): String {
|
||||
lateinit var str: String
|
||||
try {
|
||||
println(str)
|
||||
return "Should throw an exception"
|
||||
}
|
||||
catch (e: UninitializedPropertyAccessException) {
|
||||
return "OK"
|
||||
}
|
||||
catch (e: Throwable) {
|
||||
return "Unexpected exception: ${e::class}"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user