Files
kotlin-fork/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/IfStatement.fir.kt
T
simon.ogorodnik 34e6649d31 [FIR] Harden check of argument type properly
Before this commit, nullable argument could match not null parameter.
Now we require also correct nullability that breaks some cases
2020-02-03 16:45:18 +03:00

32 lines
567 B
Kotlin
Vendored

// !CHECK_TYPE
fun ifThen(x: Int?) {
if (x!! == 0) {
checkSubtype<Int>(x)
}
checkSubtype<Int>(x)
}
fun ifElse(x: Int?) {
if (x!! == 0) else {
checkSubtype<Int>(x)
}
checkSubtype<Int>(x)
}
fun ifThenElse(x: Int?) {
if (x!! == 0) {
checkSubtype<Int>(x)
} else {
checkSubtype<Int>(x)
}
checkSubtype<Int>(x)
}
fun ifIs(x: Int?, cond: Boolean) {
if ((x is Int) == cond) {
<!INAPPLICABLE_CANDIDATE!>checkSubtype<!><Int>(x)
}
<!INAPPLICABLE_CANDIDATE!>checkSubtype<!><Int>(x)
}