22c2d8b563
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
15 lines
311 B
Kotlin
Vendored
15 lines
311 B
Kotlin
Vendored
// 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}"
|
|
}
|
|
} |