Dotty Documentation

0.3.0-bin-SNAPSHOT

object TypeErasure

Erased types are:

ErasedValueType TypeRef(prefix is ignored, denot is ClassDenotation) TermRef(prefix is ignored, denot is SymDenotation) JavaArrayType AnnotatedType MethodType ThisType SuperType ClassInfo (NoPrefix, ...) NoType NoPrefix WildcardType ErrorType

only for isInstanceOf, asInstanceOf: PolyType, TypeParamRef, TypeBounds

[-] Constructors

[-] Members

[+] final class CachedErasedValueType
[+] abstract case class ErasedValueType

A type representing the semi-erasure of a derived value class, see SIP-15 where it's called "C$unboxed" for a class C. Derived value classes are erased to this type during Erasure (when semiEraseVCs = true) and subsequently erased to their underlying type during ElimErasedValueType. This type is outside the normal Scala class hierarchy: it is a subtype of no other type and is a supertype only of Nothing. This is because this type is only useful for type adaptation (see [[Erasure.Boxing#adaptToType]]).

[+] object ErasedValueType
[+] private val erasures : Array [ TypeErasure ]
[+] def erasedGlb ( tp1: Type , tp2: Type , isJava: Boolean ) ( implicit ctx: Context ) : Type

The erased greatest lower bound picks one of the two argument types. It prefers, in this order: - arrays over non-arrays - subtypes over supertypes, unless isJava is set - real classes over traits

[+] def erasedLub ( tp1: Type , tp2: Type ) ( implicit ctx: Context ) : Type

The erased least upper bound is computed as follows - if both argument are arrays of objects, an array of the erased lub of the element types - if both arguments are arrays of same primitives, an array of this primitive - if one argument is array of primitives and the other is array of objects, Object - if one argument is an array, Object - otherwise a common superclass or trait S of the argument classes, with the following two properties: S is minimal: no other common superclass or trait derives from S S is last : in the linearization of the first argument type tp1 there are no minimal common superclasses or traits that come after S. The reason to pick last is that we prefer classes over traits that way, which leads to more predictable bytecode and (?) faster dynamic dispatch.

[+] def erasedRef ( tp: Type ) ( implicit ctx: Context ) : Type

The erasure of a top-level reference. Differs from normal erasure in that TermRefs are kept instead of being widened away.

[+] def erasure ( tp: Type ) ( implicit ctx: Context ) : Type

The standard erasure of a Scala type. Value classes are erased as normal classes.

[+] private def erasureCtx ( implicit ctx: Context ) : Context

The current context with a phase no later than erasure

[+] private def erasureFn ( isJava: Boolean , semiEraseVCs: Boolean , isConstructor: Boolean , wildcardOK: Boolean ) : TypeErasure

Produces an erasure function. See the documentation of the class [[TypeErasure]] for a description of each parameter.

[+] private def erasureIdx ( isJava: Boolean , semiEraseVCs: Boolean , isConstructor: Boolean , wildcardOK: Boolean ) : Int
[+] def hasStableErasure ( tp: Type ) ( implicit ctx: Context ) : Boolean

Does the (possibly generic) type tp have the same erasure in all its possible instantiations?

[+] def isErasedType ( tp: Type ) ( implicit ctx: Context ) : Boolean

A predicate that tests whether a type is a legal erased type. Only asInstanceOf and isInstanceOf may have types that do not satisfy the predicate. ErasedValueType is considered an erased type because it is valid after Erasure (it is eliminated by ElimErasedValueType).

[+] def isUnboundedGeneric ( tp: Type ) ( implicit ctx: Context ) : Boolean

Is tp an abstract type or polymorphic type parameter that has Any, AnyVal, or a universal trait as upper bound and that is not Java defined? Arrays of such types are erased to Object instead of Object[].

[+] def sigName ( tp: Type , isJava: Boolean ) ( implicit ctx: Context ) : TypeName
[+] def transformInfo ( sym: Symbol , tp: Type ) ( implicit ctx: Context ) : Type

The symbol's erased info. This is the type's erasure, except for the following symbols:

  • For $asInstanceOf : [T]T
  • For $isInstanceOf : [T]Boolean
  • For all abstract types : = ?
  • For companion methods : the erasure of their type with semiEraseVCs = false. The signature of these methods are used to keep a link between companions and should not be semi-erased.
  • For Java-defined symbols: : the erasure of their type with isJava = true, semiEraseVCs = false. Semi-erasure never happens in Java.
  • For all other symbols : the semi-erasure of their types, with isJava, isConstructor set according to symbol.
[+] def valueErasure ( tp: Type ) ( implicit ctx: Context ) : Type

The value class erasure of a Scala type, where value classes are semi-erased to ErasedValueType (they will be fully erased in [[ElimErasedValueType]]).