Files
kotlin-fork/compiler/testData/diagnostics/tests/dataFlow/EmptyIf.kt
T
2015-04-29 16:33:24 +02:00

25 lines
539 B
Kotlin
Vendored

// !CHECK_TYPE
fun f1(s: String?) {
if (s!! == "");
checkSubtype<String>(<!DEBUG_INFO_SMARTCAST!>s<!>)
}
fun f2(s: Number?) {
if (s is Int);
checkSubtype<Int>(<!TYPE_MISMATCH!>s<!>)
if (s as Int == 42);
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>s<!>)
}
fun f3(s: Number?) {
if (s is Int && s <!USELESS_CAST!>as Int<!> == 42);
checkSubtype<Int>(<!TYPE_MISMATCH!>s<!>)
}
fun f4(s: Int?) {
var u = <!IMPLICIT_CAST_TO_UNIT_OR_ANY!>if (s!! == 42)<!>;
if (u == Unit) u = if (s == 239);
return u
}