Always null detection

This commit is contained in:
Mikhail Glukhikh
2015-11-06 17:54:05 +03:00
parent ed1c94d0f9
commit 2d9fbf5696
40 changed files with 140 additions and 75 deletions
@@ -1,8 +1,8 @@
fun test() {
val out : Int? = null
val x : Nothing? = null
if (out != x)
if (out != <!ALWAYS_NULL!>x<!>)
<!DEBUG_INFO_SMARTCAST!>out<!>.plus(1)
if (out == x) return
if (out == <!ALWAYS_NULL!>x<!>) return
<!DEBUG_INFO_SMARTCAST!>out<!>.plus(1)
}
@@ -25,7 +25,7 @@ fun f3(s: Int?): Int {
fun f4(s: Int?): Int {
return when {
s == 4 -> <!DEBUG_INFO_SMARTCAST!>s<!>
s == null -> <!TYPE_MISMATCH!>s<!>
s == null -> <!ALWAYS_NULL, TYPE_MISMATCH!>s<!>
else -> <!DEBUG_INFO_SMARTCAST!>s<!>
}
}
@@ -21,8 +21,8 @@ fun main(args : Array<String>) {
foo(x<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>)
foo(<!DEBUG_INFO_SMARTCAST!>x<!>)
} else {
foo(<!TYPE_MISMATCH!>x<!>)
<!UNREACHABLE_CODE!>foo(<!><!DEBUG_INFO_SMARTCAST!>x<!>!!<!UNREACHABLE_CODE!>)<!>
foo(<!ALWAYS_NULL, TYPE_MISMATCH!>x<!>)
<!UNREACHABLE_CODE!>foo(<!><!ALWAYS_NULL, DEBUG_INFO_SMARTCAST!>x<!>!!<!UNREACHABLE_CODE!>)<!>
<!UNREACHABLE_CODE!>foo(<!DEBUG_INFO_SMARTCAST!>x<!>)<!>
}