Files
kotlin-fork/compiler/testData/diagnostics/tests/smartCasts/equals.fir.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

26 lines
435 B
Kotlin
Vendored

fun foo(x: String?) = x
class Test
class TestWithEquals {
override fun equals(other: Any?) = super.equals(other)
}
fun bar(i: Test?) {
if (i == null) foo(i)
}
fun bar(i: TestWithEquals?) {
if (i == null) foo(i)
if (null == i) foo(i)
when (i) {
null -> foo(i)
}
}
fun gav(i: TestWithEquals?, j: TestWithEquals?) {
if (j == null) {
if (i == j) foo(<!ARGUMENT_TYPE_MISMATCH!>i<!>)
}
}