FIR checker: warn unnecessary non-null assertions
This commit is contained in:
committed by
Mikhail Glukhikh
parent
5229d4e4f4
commit
2ecb6733ed
@@ -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)
|
||||
|
||||
+2
-2
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user