I’m surprised to find that matches on Java enums can not be guaranteed to compile into a tableswitch or lookupswitch:
public enum JEnum {
THIS,
THAT,
THOSE
}
class Test {
def map(value: JEnum): JEnum = (value: @switch) match {
case JEnum.THIS => JEnum.THAT
case JEnum.THAT => JEnum.THOSE
case JEnum.THOSE => JEnum.THIS
}
}
could not emit switch for @switch annotated match
def map(value: JEnum): JEnum = (value: @switch) match {
Is there a specific limitation that prevents Scala from considering Java enums to be a constant literal?