KT-1680 Warn if non-null variable is compared to null

#KT-1680 fixed
This commit is contained in:
Svetlana Isakova
2012-04-19 14:20:36 +04:00
parent 44c5e0ca2e
commit 558d1a0e2f
3 changed files with 23 additions and 0 deletions
@@ -0,0 +1,14 @@
//KT-1680 Warn if non-null variable is compared to null
package kt1680
fun foo() {
val x = 1
if (<!SENSELESS_COMPARISON!>x != null<!>) {} // <-- need a warning here!
if (<!SENSELESS_COMPARISON!>x == null<!>) {}
if (<!SENSELESS_COMPARISON!>null != x<!>) {}
if (<!SENSELESS_COMPARISON!>null == x<!>) {}
val y : Int? = 1
if (y != null) {}
if (y == null) {}
}