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
This commit is contained in:
Alexander Udalov
2019-10-18 16:33:34 +02:00
parent 35d7bb4a26
commit 95be7171bc
7 changed files with 53 additions and 13 deletions
@@ -0,0 +1,14 @@
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)