Files
kotlin-fork/compiler/testData/diagnostics/tests/smartCasts/alwaysNull.fir.kt
T
Jinseong Jeon e72ddbcbfe FIR checker: differentiate UNSAFE_CALL from INAPPLICABLE_CANDIDATE
To do so, inside the root cause of inapplicable candidate errors,
we will record expected/actual type of receiver, if any.
That will help identifying inapplicable calls on nullable receiver.
2021-01-29 16:54:23 +03:00

24 lines
435 B
Kotlin
Vendored

// !WITH_NEW_INFERENCE
fun foo(): String {
var s: String?
s = null
s?.length
s.<!UNSAFE_CALL!>length<!>
if (s == null) return s!!
var t: String? = "y"
if (t == null) t = "x"
var x: Int? = null
if (x == null) <!UNRESOLVED_REFERENCE!>x += null<!>
return t + s
}
fun String?.gav() {}
fun bar(s: String?) {
if (s != null) return
s.gav()
s as? String
s as String?
s as String
}