It isn’t. The type is erased. Type erasure doesn’t mean the type is just, like, hidden away somewhere and you have to do a little extra dance to get to it. It is erased, it is GONE, it no longer exists, it has joined the choir invisible. This is true in both Java and Scala.
In the case of Scala’s immutable collections like scala.collection.immutable.List
the situation is even more extreme — the empty List[Int]
and the empty List[Double]
are literally one and the same value:
scala 2.13.3> List[Double]() eq List[Int]()
val res0: Boolean = true
note the eq
, which tests for reference equality.