When by enum:
Generate TABLESWITCH/LOOKUPSWITCH bytecode command in case of "when" by enum entries
This commit is contained in:
committed by
Evgeny Gerashchenko
parent
b2aa249817
commit
5a1c995b5c
@@ -0,0 +1,36 @@
|
||||
package abc.foo
|
||||
|
||||
enum class Season {
|
||||
WINTER
|
||||
SPRING
|
||||
SUMMER
|
||||
AUTUMN
|
||||
}
|
||||
|
||||
class A {
|
||||
public fun bar1(x : Season) : String {
|
||||
when (x) {
|
||||
Season.WINTER, Season.SPRING -> return "winter_spring"
|
||||
Season.SPRING -> return "spring"
|
||||
Season.SUMMER -> return "summer"
|
||||
}
|
||||
|
||||
return "autumn";
|
||||
}
|
||||
|
||||
public fun bar2(y : Season) : String {
|
||||
return bar3(y) { x ->
|
||||
when (x) {
|
||||
Season.WINTER, Season.SPRING -> "winter_spring"
|
||||
Season.SPRING -> "spring"
|
||||
Season.SUMMER -> "summer"
|
||||
else -> "autumn"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun bar3(x : Season, block : (Season) -> String) = block(x)
|
||||
}
|
||||
|
||||
// 2 TABLESWITCH
|
||||
// 1 @abc/foo/A\$WhenMappings\.class
|
||||
Reference in New Issue
Block a user