mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-08 15:53:19 +00:00
A lookupswitch or tableswitch can be used if all conditions are equality
checks to constants. To be more specific, it can be done if:
1. All conditions are CALL 'EQEQ(Any?, Any?)': Boolean
2. All types of variables involved in comparison are in the same group
of Char/Byte/Short/Int, String or enum.
3. All arg0 refer to the same value.
4. All arg1 are IrConst<*>.
Change-Id: Ifd7cb618395f6c5cc64601018b446f0bb7f5891c
17 lines
246 B
Kotlin
Vendored
17 lines
246 B
Kotlin
Vendored
const val A = 10
|
|
private const val B = 20
|
|
|
|
object Constants {
|
|
const val C = 30
|
|
}
|
|
|
|
fun foo(state: Int) {
|
|
when (state) {
|
|
A -> return
|
|
B -> return
|
|
Constants.C -> return
|
|
else -> return
|
|
}
|
|
}
|
|
|
|
// 1 LOOKUPSWITCH |