When by enum:

Generate TABLESWITCH/LOOKUPSWITCH bytecode command in case of "when" by enum entries
This commit is contained in:
Denis Zharkov
2014-07-15 19:55:39 +04:00
committed by Evgeny Gerashchenko
parent b2aa249817
commit 5a1c995b5c
29 changed files with 1059 additions and 12 deletions
@@ -0,0 +1,27 @@
import kotlin.test.assertEquals
enum class Season {
WINTER
SPRING
SUMMER
AUTUMN
}
fun bar1(x : Season) : String {
return when (x) {
Season.WINTER, Season.SPRING -> "winter_spring"
Season.SUMMER -> "summer"
else -> "autumn"
}
}
fun bar2(x : Season) : String {
return when (x) {
Season.WINTER, Season.SPRING -> "winter_spring"
Season.SUMMER -> "summer"
Season.AUTUMN -> "autumn"
}
}
// 2 TABLESWITCH
// 1 @_DefaultPackage-expression-.*\$WhenMappings\.class