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:
Dmitry Petrov
2018-03-15 13:52:07 +03:00
parent 7be4f5d31f
commit 22c2d8b563
6 changed files with 81 additions and 22 deletions
@@ -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}"
}
}