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
@@ -18,18 +18,18 @@ fun g(a: SomeClass?) {
b = "Hello"
if (b != null) {
// 'a' cannot be cast to SomeSubClass!
a.<!UNSAFE_CALL!>hashCode<!>()
a<!UNSAFE_CALL!>.<!>hashCode()
a.<!UNRESOLVED_REFERENCE!>foo<!>
(a as? SomeSubClass).<!UNSAFE_CALL!>foo<!>
(a as? SomeSubClass)<!UNSAFE_CALL!>.<!>foo
(a as SomeSubClass).foo
}
var c = a as? SomeSubClass
c = Impl
if (c != null) {
// 'a' cannot be cast to SomeSubClass
a.<!UNSAFE_CALL!>hashCode<!>()
a<!UNSAFE_CALL!>.<!>hashCode()
a.<!UNRESOLVED_REFERENCE!>foo<!>
(a as? SomeSubClass).<!UNSAFE_CALL!>foo<!>
(a as? SomeSubClass)<!UNSAFE_CALL!>.<!>foo
c.hashCode()
c.foo
}
@@ -41,18 +41,18 @@ fun f(a: SomeClass?) {
if (aa as? SomeSubClass != null) {
aa = null
// 'aa' cannot be cast to SomeSubClass
aa.<!UNSAFE_CALL!>hashCode<!>()
aa<!UNSAFE_CALL!>.<!>hashCode()
aa.<!UNRESOLVED_REFERENCE!>foo<!>
(aa as? SomeSubClass).<!UNSAFE_CALL!>foo<!>
(aa as? SomeSubClass)<!UNSAFE_CALL!>.<!>foo
(aa as SomeSubClass).foo
}
val b = (aa as? SomeSubClass)?.foo
aa = null
if (b != null) {
// 'aa' cannot be cast to SomeSubClass
aa.<!UNSAFE_CALL!>hashCode<!>()
aa<!UNSAFE_CALL!>.<!>hashCode()
aa.<!UNRESOLVED_REFERENCE!>foo<!>
(aa as? SomeSubClass).<!UNSAFE_CALL!>foo<!>
(aa as? SomeSubClass)<!UNSAFE_CALL!>.<!>foo
(aa as SomeSubClass).foo
}
aa = a
@@ -61,7 +61,7 @@ fun f(a: SomeClass?) {
// 'c' can be cast to SomeSubClass
aa.hashCode()
aa.foo
(aa as? SomeSubClass).<!UNSAFE_CALL!>foo<!>
(aa as? SomeSubClass)<!UNSAFE_CALL!>.<!>foo
c.hashCode()
c.foo
}