FIR checker: warn unnecessary non-null assertions
This commit is contained in:
committed by
Mikhail Glukhikh
parent
5229d4e4f4
commit
2ecb6733ed
+1
-1
@@ -6,7 +6,7 @@ interface G {
|
||||
}
|
||||
|
||||
fun foo1(a: Int?, b: G) {
|
||||
b[a!!, a!!] = a
|
||||
b[a!!, a<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>] = a
|
||||
checkSubtype<Int>(a)
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
fun foo1(a: Int?, b: Array<Array<Int>>) {
|
||||
b[a!!][a!!] = a
|
||||
b[a!!][a<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>] = a
|
||||
checkSubtype<Int>(a)
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ fun bar(x: Int) = x + 1
|
||||
|
||||
fun f1(x: Int?) {
|
||||
<!INAPPLICABLE_CANDIDATE!>bar<!>(x)
|
||||
if (x != null) bar(x!!)
|
||||
if (x != null) bar(x<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>)
|
||||
if (x == null) bar(x!!)
|
||||
}
|
||||
|
||||
@@ -11,13 +11,13 @@ fun f2(x: Int?) {
|
||||
}
|
||||
|
||||
fun f3(x: Int?) {
|
||||
if (x != null) bar(x!!) else x!!
|
||||
if (x != null) bar(x<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>) else x!!
|
||||
}
|
||||
|
||||
fun f4(x: Int?) {
|
||||
if (x == null) x!! else bar(x!!)
|
||||
if (x == null) x!! else bar(x<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>)
|
||||
}
|
||||
|
||||
fun f5(x: Int?) {
|
||||
if (x == null) else bar(x!!)
|
||||
if (x == null) else bar(x<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>)
|
||||
}
|
||||
|
||||
+1
-1
@@ -26,5 +26,5 @@ fun foo() {
|
||||
if (z != null) bar(z)
|
||||
<!INAPPLICABLE_CANDIDATE!>bar<!>(z)
|
||||
bar(z!!)
|
||||
if (z != null) bar(z!!)
|
||||
if (z != null) bar(z<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user