FIR checker: warn unnecessary non-null assertions
This commit is contained in:
committed by
Mikhail Glukhikh
parent
5229d4e4f4
commit
2ecb6733ed
@@ -28,7 +28,7 @@ fun testElvis(x: Any?) {
|
||||
}
|
||||
|
||||
fun testExclExcl() {
|
||||
val y = :: unresolved!!
|
||||
val y = :: unresolved<!NOT_NULL_ASSERTION_ON_CALLABLE_REFERENCE!>!!<!>
|
||||
}
|
||||
|
||||
fun testTry() {
|
||||
|
||||
Vendored
-24
@@ -1,24 +0,0 @@
|
||||
//KT-4204 ConstraintSystem erased after resolution completion
|
||||
package c
|
||||
|
||||
public abstract class TestBug1() {
|
||||
|
||||
public fun m3(position: Int) {
|
||||
position(m1().second!!)
|
||||
}
|
||||
|
||||
public fun m4(position: (Int)->Int) {
|
||||
position(m1().second)
|
||||
}
|
||||
|
||||
<!INCOMPATIBLE_MODIFIERS!>private<!> <!INCOMPATIBLE_MODIFIERS!>abstract<!> fun m1(): Pair<Int, Int>
|
||||
|
||||
private fun position(p: Int) {}
|
||||
|
||||
}
|
||||
|
||||
//from library
|
||||
public class Pair<out A, out B> (
|
||||
public val first: A,
|
||||
public val second: B
|
||||
)
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
//KT-4204 ConstraintSystem erased after resolution completion
|
||||
package c
|
||||
|
||||
|
||||
+1
-1
@@ -25,5 +25,5 @@ fun testDataFlowInfoAfterExclExcl(a: Int?) {
|
||||
}
|
||||
|
||||
fun testUnnecessaryExclExcl(a: Int) {
|
||||
doInt(a!!) //should be warning
|
||||
doInt(a<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>) //should be warning
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user