The type system does not know about boxing at this level. But he knows that if there is Any
, then the Long
box really (supposedly) should just be Long
(from the AnyVal
part of the class inheritance tree). So:
val someRef: java.lang.Long = 42L (someRef: Any) match { case x : Long => println("The answer is " + x) case _ => println("What answer?") }
source share