2ecba6ac39
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)
55 lines
738 B
Kotlin
Vendored
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
|
|
}
|
|
}
|