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
+22
@@ -0,0 +1,22 @@
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
enum class Season {
|
||||
WINTER
|
||||
SPRING
|
||||
SUMMER
|
||||
AUTUMN
|
||||
}
|
||||
|
||||
fun foo(x : Season, block : (Season) -> String) = block(x)
|
||||
|
||||
fun box() : String {
|
||||
return foo(Season.SPRING) {
|
||||
x -> when (x) {
|
||||
Season.SPRING -> "OK"
|
||||
else -> "fail"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 1 LOOKUPSWITCH
|
||||
// 1 @_DefaultPackage-functionLiteralInTopLevel-[a-z0-9]+\$WhenMappings.class
|
||||
Reference in New Issue
Block a user