Files
kotlin-fork/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2146.fir.kt
T

56 lines
761 B
Kotlin
Vendored

// !WITH_NEW_INFERENCE
//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
}
}