Files
kotlin-fork/compiler/testData/codegen/box/smartCasts/nullSmartCast.kt
T
Tianyu Geng 4726dcce40 FIR DFA: smartcast variable to Nothing? on null assignment
In order to make resolution still work for members not available from
`Nothing`, we track the type without `Nothing?` and use that for
resolution instead.
2021-08-06 22:57:15 +03:00

11 lines
206 B
Kotlin
Vendored

// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: NULL_REF_CAST
fun String?.foo() = this ?: "OK"
fun foo(i: Int?): String {
if (i == null) return i.foo()
return "$i"
}
fun box() = foo(null)