Files
kotlin-fork/compiler/fir/analysis-tests/testData/resolve/exhaustiveness_enum.kt
T
2020-03-19 09:51:01 +03:00

56 lines
809 B
Kotlin
Vendored

enum class Enum {
A, B, C
}
fun test_1(e: Enum) {
val a = when (e) {
Enum.A -> 1
Enum.B -> 2
}
val b = when (e) {
Enum.A -> 1
Enum.B -> 2
is String -> 3
}
val c = when (e) {
Enum.A -> 1
Enum.B -> 2
Enum.C -> 3
}
val d = when (e) {
Enum.A -> 1
else -> 2
}
}
fun test_2(e: Enum?) {
val a = when (e) {
Enum.A -> 1
Enum.B -> 2
Enum.C -> 3
}
val a = when (e) {
Enum.A -> 1
Enum.B -> 2
Enum.C -> 3
null -> 4
}
val a = when (e) {
Enum.A -> 1
Enum.B -> 2
Enum.C -> 3
else -> 4
}
}
fun test_3(e: Enum) {
val a = when (e) {
Enum.A, Enum.B -> 1
Enum.C -> 2
}
}