FIR checker: warn unnecessary non-null assertions

This commit is contained in:
Jinseong Jeon
2021-04-01 11:44:47 -07:00
committed by Mikhail Glukhikh
parent 5229d4e4f4
commit 2ecb6733ed
72 changed files with 268 additions and 246 deletions
@@ -1,6 +0,0 @@
fun calc(x: List<String>?): Int {
// After KT-5840 fix !! assertion should become unnecessary here
x?.get(x!!.size - 1)
// x?. or x!! above should not provide smart cast here
return x<!UNSAFE_CALL!>.<!>size
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
fun calc(x: List<String>?): Int {
// After KT-5840 fix !! assertion should become unnecessary here
x?.get(x<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.size - 1)
@@ -10,5 +10,5 @@ fun foo(y: MyClass?): Int {
fun bar(y: MyClass?) {
y?.x!!.length
// !! is NOT necessary here, because y?.x != null
y!!.x
}
y<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.x
}