Instance Constructors
-
Value Members
-
final
def
!=(arg0: Any): Boolean
-
final
def
##(): Int
-
final
def
==(arg0: Any): Boolean
-
final
def
asInstanceOf[T0]: T0
-
-
def
clone(): AnyRef
-
val
default: Tree
-
-
def
finalize(): Unit
-
final
def
getClass(): Class[_]
-
final
def
isInstanceOf[T0]: Boolean
-
-
final
def
notify(): Unit
-
final
def
notifyAll(): Unit
-
implicit
val
pos: Position
-
val
selector: Tree
-
def
show: String
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
-
val
tpe: Type
-
final
def
wait(): Unit
-
final
def
wait(arg0: Long, arg1: Int): Unit
-
final
def
wait(arg0: Long): Unit
A break-free switch (without fallthrough behavior).
Unlike a JavaScript switch, it can be used in expression position. It supports alternatives explicitly (hence the
List[MatchableLiteral]in cases), whereas in a switch one would use the fallthrough behavior to implement alternatives. (This is not a pattern matching construct like in Scala.)The selector must be either an
int(IntType) or ajava.lang.String. The cases can be anyMatchableLiteral, even if they do not make sense for the type of the selecter (they simply will never match).Because
+0.0 === -0.0in JavaScript, and because those semantics are used in a JSswitch, we have to prevent the selector from ever being-0.0. Otherwise, it would be matched by acase IntLiteral(0). At the same time, we must allow at leastintandjava.lang.Stringto support all switchablematches from Scala. Since the latter two have no common super type that does not allow-0.0, we really have to special-case those two types.This is also why we restrict
MatchableLiterals toIntLiteral,StringLiteralandNull. Allowing more cases would only make IR checking more complicated, without bringing any added value.