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
@@ -13,18 +13,18 @@ fun test(x : Int?, a : A?) {
x?.plus(1)
x <!NONE_APPLICABLE!>+<!> 1
<!UNSAFE_CALL!>-<!>x
x.<!UNSAFE_CALL!>unaryMinus<!>()
x<!UNSAFE_CALL!>.<!>unaryMinus()
x?.unaryMinus()
a.<!UNSAFE_CALL!>plus<!>(1)
a<!UNSAFE_CALL!>.<!>plus(1)
a?.plus(1)
a <!UNSAFE_CALL!>plus<!> 1
a <!UNSAFE_CALL!>+<!> 1
<!UNSAFE_CALL!>-<!>a
a.<!UNSAFE_CALL!>unaryMinus<!>()
a<!UNSAFE_CALL!>.<!>unaryMinus()
a?.unaryMinus()
a.<!UNSAFE_CALL!>div<!>(1)
a<!UNSAFE_CALL!>.<!>div(1)
a <!UNSAFE_CALL!>/<!> 1
a <!UNSAFE_CALL!>div<!> 1
a?.div(1)
@@ -36,6 +36,6 @@ fun test(x : Int?, a : A?) {
1 <!UNSAFE_CALL!>in<!> a
a <!UNSAFE_CALL!>contains<!> 1
a.<!UNSAFE_CALL!>contains<!>(1)
a<!UNSAFE_CALL!>.<!>contains(1)
a?.contains(1)
}
@@ -7,7 +7,7 @@ fun main() {
val x: Foo? = null
val y: Foo? = null
x.<!UNSAFE_CALL!>foo<!>(y)
x<!UNSAFE_CALL!>.<!>foo(y)
x!!.<!INAPPLICABLE_CANDIDATE!>foo<!>(y)
x.foo(y!!)
x!!.foo(y!!)
@@ -16,8 +16,8 @@ fun main() {
val b: Foo? = null
val c: Foo? = null
a.<!UNSAFE_CALL!>foo<!>(b.<!UNSAFE_CALL!>foo<!>(c))
a!!.foo(b.<!UNSAFE_CALL!>foo<!>(c))
a<!UNSAFE_CALL!>.<!>foo(b<!UNSAFE_CALL!>.<!>foo(c))
a!!.foo(b<!UNSAFE_CALL!>.<!>foo(c))
a.foo(b!!.<!INAPPLICABLE_CANDIDATE!>foo<!>(c))
a!!.foo(b!!.<!INAPPLICABLE_CANDIDATE!>foo<!>(c))
a.foo(b.foo(c!!))
@@ -6,8 +6,8 @@ fun A.bar() {}
fun A?.buzz() {}
fun test(a : A?) {
a.<!UNSAFE_CALL!>foo<!>() // error
a.<!UNSAFE_CALL!>bar<!>() // error
a<!UNSAFE_CALL!>.<!>foo() // error
a<!UNSAFE_CALL!>.<!>bar() // error
a.buzz()
a?.foo()
@@ -34,8 +34,8 @@ fun A?.test3() {
<!UNSAFE_CALL!>bar<!>() // error
buzz()
this.<!UNSAFE_CALL!>foo<!>() // error
this.<!UNSAFE_CALL!>bar<!>() // error
this<!UNSAFE_CALL!>.<!>foo() // error
this<!UNSAFE_CALL!>.<!>bar() // error
this.buzz()
this?.foo()
@@ -1,13 +0,0 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE
//KT-1270 Poor highlighting when trying to dereference a nullable reference
package kt1270
fun foo() {
val sc = java.util.HashMap<String, SomeClass>()[""]
val value = sc.<!UNSAFE_CALL!>value<!>
}
private class SomeClass() {
val value : Int = 5
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_VARIABLE
//KT-1270 Poor highlighting when trying to dereference a nullable reference
@@ -5,7 +5,7 @@ package e
fun main() {
val compareTo = 1
val s: String? = null
s.<!UNSAFE_CALL!>compareTo<!>("")
s<!UNSAFE_CALL!>.<!>compareTo("")
val bar = 2
s.<!UNRESOLVED_REFERENCE!>bar<!>()