Files
kotlin/compiler/testData/codegen/box/when/enumOptimization/nullIsTheFirstEntry.kt
Alexander Udalov 95be7171bc JVM IR: fix "null" as the first entry in MappedEnumWhenLowering
If "null" was the first entry in an optimizable "when" over enum,
mapRuntimeEnumEntry was called before mapConstEnumEntry, and the
$WhenMappings field was not created. Now both mapConstEnumEntry and
mapRuntimeEnumEntry create this field on the first access
2019-10-23 11:03:22 +02:00

15 lines
201 B
Kotlin
Vendored

enum class E {
A, B;
}
fun foo(e: E?): String {
val c = when (e) {
null -> "Fail: null"
E.B -> "OK"
E.A -> "Fail: A"
}
return c
}
fun box(): String = foo(E.B)