Files
kotlin-fork/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/IfThenElse.kt
T
2013-12-11 19:53:50 +04:00

31 lines
699 B
Kotlin

fun bar(x: Int): Int = x + 1
fun foo() {
val x: Int? = null
bar(if (x == null) 0 else <!DEBUG_INFO_AUTOCAST!>x<!>)
if (x == null) {
bar(<!TYPE_MISMATCH!>x<!>)
return
} else {
bar(<!DEBUG_INFO_AUTOCAST!>x<!>)
}
bar(<!DEBUG_INFO_AUTOCAST!>x<!>)
val y: Int? = null
if (y is Int) {
bar(<!DEBUG_INFO_AUTOCAST!>y<!>)
} else {
bar(<!TYPE_MISMATCH!>y<!>)
return
}
bar(<!DEBUG_INFO_AUTOCAST!>y<!>)
val z: Int? = null
if (z != null) bar(<!DEBUG_INFO_AUTOCAST!>z<!>)
bar(<!TYPE_MISMATCH!>z<!>)
bar(z!!)
if (<!SENSELESS_COMPARISON!>z != null<!>) bar(z<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>)
}