Files
kotlin-fork/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2146.fir.kt
T
Denis.Zharkov 2ecba6ac39 Remove WITH_NEW_INFERENCE directive from all tests
This directive anyway does not make test run twice with OI, and with NI
It only once run the test with specific settings (// LANGUAGE)
and ignores irrelevant (OI or NI tags)
2021-05-25 13:28:26 +03:00

55 lines
738 B
Kotlin
Vendored

//KT-2146 Nullability casts in when.
package kt2146
fun f1(s: Int?): Int {
return when (s) {
null -> 3
else -> s
}
}
fun f2(s: Int?): Int {
return when (s) {
!is Int -> s
else -> s
}
}
fun f3(s: Int?): Int {
return when (s) {
is Int -> s
else -> s
}
}
fun f4(s: Int?): Int {
return when {
s == 4 -> s
s == null -> s
else -> s
}
}
fun f5(s: Int?): Int {
return when (s) {
s -> s
s!! -> s
s -> s
else -> 0
}
}
fun f6(s: Int?): Int {
return when {
s is Int -> s
else -> s
}
}
fun f7(s: Int?): Int {
return when {
s !is Int -> s
else -> s
}
}