You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"intlike type" is any of Int, Short, Byte, or Char.
"intlike" means an intlike literal or intlike identifier.
"intlike literal" means any literal constant with an intlike type.
"intlike identifier" means an identifier which can be statically determined to have the following properties:
immutable (i.e. a val)
not overridable (i.e. final or enclosed in a final container)
assigned a value which can be statically reduced to an intlike literal. This means arithmetic operations only, on intlikes.
scala should generate tableswitch/lookupswitch bytecode whenever the following conditions hold:
a) the scrutinee is any expression with an intlike result type.
a1) or, if b) and c) hold, then if the scrutinee is AnyVal or Any, a switch can still be generated by inserting if/then/else logic before the switch.
b) all non-default cases are intlike.
c) if there is a default case, it either has no type annotation, or a type annotation which matches all intlike values.
At present, an identifier in a match statement will suppress the creation of a switch statement 100% of the time if it makes it to the pattern matcher stage. When scala's constant folder replaces the identifier with the constant before reaching that point, the switch can be created; but this takes place only in a fraction of the cases where it's desirable.
The text was updated successfully, but these errors were encountered:
this ticket seems not to have been looked at in a long time. anyone know what the current state is, in Scala 2 and/or 3? not sure whether to add the "help wanted" label and/or the "fixed in Scala 3" labels
(I'm consolidating related tickets: see also #1452, #1456, #1457, #1458, #6955, #6956)
Terms:
scala should generate tableswitch/lookupswitch bytecode whenever the following conditions hold:
At present, an identifier in a match statement will suppress the creation of a switch statement 100% of the time if it makes it to the pattern matcher stage. When scala's constant folder replaces the identifier with the constant before reaching that point, the switch can be created; but this takes place only in a fraction of the cases where it's desirable.
The text was updated successfully, but these errors were encountered: