FIR: report UNSAFE_CALL on dot when possible

This commit is contained in:
Mikhail Glukhikh
2021-01-29 10:25:59 +03:00
parent 0ee4f1f393
commit 7d4eaefd36
249 changed files with 1208 additions and 1649 deletions
@@ -11,22 +11,22 @@ fun String.notNullLet(f: (String) -> Unit) = f(this)
fun test(foo: Foo?) {
foo?.bar?.gav.let {
// Error, foo?.bar?.gav is nullable
it.<!UNSAFE_CALL!>length<!>
it<!UNSAFE_CALL!>.<!>length
// Error, foo is nullable
foo.<!UNSAFE_CALL!>bar<!>.gav.length
foo<!UNSAFE_CALL!>.<!>bar.gav.length
// Correct
foo?.bar?.gav?.length
}
foo?.bar?.gav.call { it }?.notNullLet {
foo.<!UNSAFE_CALL!>hashCode<!>()
foo.<!UNSAFE_CALL!>bar<!>.hashCode()
foo<!UNSAFE_CALL!>.<!>hashCode()
foo<!UNSAFE_CALL!>.<!>bar.hashCode()
}
}
fun testNotNull(foo: Foo) {
val s: String? = ""
foo.baz(s!!)?.gav.let {
it.<!UNSAFE_CALL!>length<!>
it<!UNSAFE_CALL!>.<!>length
// Ok because of foo.
s.length.hashCode()
}
@@ -35,7 +35,7 @@ fun testNotNull(foo: Foo) {
fun testNullable(foo: Foo?) {
val s: String? = ""
foo?.baz(s!!)?.gav.let {
it.<!UNSAFE_CALL!>length<!>
it<!UNSAFE_CALL!>.<!>length
// Ok because of foo?.
s?.length?.hashCode()
}