Types

object Types
class Object
trait Matchable
class Any

Type members

Classlikes

abstract class AliasingBounds(val alias: Type) extends TypeBounds

Common supertype of TypeAlias and MatchAlias

Common supertype of TypeAlias and MatchAlias

abstract class AndOrType extends CachedGroundType with ValueType
abstract case class AndType(tp1: Type, tp2: Type) extends AndOrType
Companion
object
object AndType
Companion
class
abstract case class AnnotatedType(parent: Type, annot: Annotation) extends CachedProxyType with ValueType

An annotated type tpe @ annot

An annotated type tpe @ annot

Companion
object
Companion
class
abstract case class AppliedType(tycon: Type, args: List[Type]) extends CachedProxyType with ValueType

A type application C[T_1, ..., T_n]

A type application C[T_1, ..., T_n]

Companion
object
object AppliedType
Companion
class
abstract class ApproximatingTypeMap(using `x$1`: Context) extends TypeMap

A type map that approximates TypeBounds types depending on variance.

A type map that approximates TypeBounds types depending on variance.

if variance > 0 : approximate by upper bound variance < 0 : approximate by lower bound variance = 0 : propagate bounds to next outer level

trait BindingType extends Type

A trait for types that bind other types that refer to them. Instances are: LambdaType, RecType.

A trait for types that bind other types that refer to them. Instances are: LambdaType, RecType.

abstract class BoundType extends CachedProxyType with ValueType
final class CachedAndType(tp1: Type, tp2: Type) extends AndType
class CachedAnnotatedType(parent: Type, annot: Annotation) extends AnnotatedType
final class CachedAppliedType(tycon: Type, args: List[Type], hc: Int) extends AppliedType
class CachedClassInfo(prefix: Type, cls: ClassSymbol, declaredParents: List[Type], decls: Scope, selfInfo: TypeOrSymbol) extends ClassInfo
final class CachedConstantType(value: Constant) extends ConstantType
final class CachedExprType(resultType: Type) extends ExprType
abstract class CachedGroundType extends Type with CachedType

Instances of this class are cached and are not proxies.

Instances of this class are cached and are not proxies.

final class CachedJavaArrayType(elemType: Type) extends JavaArrayType
class CachedMatchType(bound: Type, scrutinee: Type, cases: List[Type]) extends MatchType
final class CachedMethodType(paramNames: List[TermName])(paramInfosExp: MethodType => List[Type], resultTypeExp: MethodType => Type, val companion: MethodTypeCompanion) extends MethodType
final class CachedOrType(tp1: Type, tp2: Type, val isSoft: Boolean) extends OrType
abstract class CachedProxyType extends TypeProxy with CachedType

Instances of this class are cached and are proxies.

Instances of this class are cached and are proxies.

class CachedRefinedType(parent: Type, refinedName: Name, refinedInfo: Type) extends RefinedType
final class CachedSuperType(thistpe: Type, supertpe: Type) extends SuperType
final class CachedTermRef(prefix: Type, designator: Designator, hc: Int) extends TermRef
final class CachedThisType(tref: TypeRef) extends ThisType
trait CachedType extends Type

A marker trait for cached types

A marker trait for cached types

final class CachedTypeRef(prefix: Type, designator: Designator, hc: Int) extends TypeRef
final class CachedWildcardType(optBounds: Type) extends WildcardType
abstract case class ClassInfo(prefix: Type, cls: ClassSymbol, declaredParents: List[Type], decls: Scope, selfInfo: TypeOrSymbol) extends CachedGroundType with TypeType

Roughly: the info of a class during a period.

Roughly: the info of a class during a period.

Value Params
cls

The class symbol.

declaredParents

The parent types of this class. These are all normalized to be TypeRefs by moving any refinements to be member definitions of the class itself. Unlike parents, the types are not seen as seen from prefix.

decls

The symbols defined directly in this class.

prefix

The prefix on which parents, decls, and selfType need to be rebased.

selfInfo

The type of this in this class, if explicitly given, NoType otherwise. If class is compiled from source, can also be a reference to the self symbol containing the type.

Companion
object
object ClassInfo
Companion
class
abstract case class ConstantType(value: Constant) extends CachedProxyType with SingletonType

A constant type with single value.

A constant type with single value.

Companion
object
object ConstantType
Companion
class
abstract class DeepTypeMap(using `x$1`: Context) extends TypeMap

A type map that maps also parents and self type of a ClassInfo

A type map that maps also parents and self type of a ClassInfo

abstract class ErrorType extends FlexType
Companion
object
object ErrorType
Companion
class
class ExistsAccumulator(p: Type => Boolean, val stopAtStatic: Boolean, forceLazy: Boolean)(using `x$4`: Context) extends TypeAccumulator[Boolean]
abstract case class ExprType(resType: Type) extends CachedProxyType with MethodicType

A by-name parameter type of the form => T, or the type of a method with no parameter list.

A by-name parameter type of the form => T, or the type of a method with no parameter list.

Companion
object
object ExprType
Companion
class
abstract class FlexType extends UncachedGroundType with ValueType

A common superclass of ErrorType and TryDynamicCallSite. Instances of this class are at the same time subtypes and supertypes of every other type.

A common superclass of ErrorType and TryDynamicCallSite. Instances of this class are at the same time subtypes and supertypes of every other type.

class ForeachAccumulator(p: Type => Unit, val stopAtStatic: Boolean)(using `x$3`: Context) extends TypeAccumulator[Unit]
abstract class HKLambda extends CachedProxyType with LambdaType
class HKTypeLambda(val paramNames: List[TypeName], @constructorOnly variances: List[Variance])(paramInfosExp: HKTypeLambda => List[TypeBounds], resultTypeExp: HKTypeLambda => Type) extends HKLambda with TypeLambda

A type lambda of the form [X_0 B_0, ..., X_n B_n] => T

A type lambda of the form [X_0 B_0, ..., X_n B_n] => T

Value Params
paramInfosExp

A function that, given the polytype itself, returns the parameter bounds B_1, ..., B_n

paramNames

The names X_0, ..., X_n

resultTypeExp

A function that, given the polytype itself, returns the result type T.

variances

The variances of the type parameters, if the type lambda carries variances, i.e. it is a bound of an abstract type or the rhs of a match alias or opaque alias. The parameter is Nil for all other lambdas. Variances are stored in the typeParams list of the lambda.

Companion
object
object IdentityTypeMap extends TypeMap

A reference to an implicit definition. This can be either a TermRef or a Implicits.RenamedImplicitRef.

A reference to an implicit definition. This can be either a TermRef or a Implicits.RenamedImplicitRef.

case class ImportType(expr: Tree) extends UncachedGroundType

The type of an import clause tree

The type of an import clause tree

abstract case class JavaArrayType(elemType: Type) extends CachedGroundType with ValueType

The type of an erased array

The type of an erased array

Companion
object
Companion
class
case class LambdaParam(tl: TypeLambda, n: Int) extends ParamInfo

The parameter of a type lambda

The parameter of a type lambda

trait LambdaType extends BindingType with TermType

The lambda type square:

The lambda type square:

LambdaType | TermLambda | TypeLambda -------------+-------------------+------------------ HKLambda | HKTermLambda | HKTypeLambda MethodOrPoly | MethodType | PolyType

abstract class LambdaTypeCompanion[N <: Name, PInfo <: Type, LT <: LambdaType]
case class LazyRef(var refFn: Context => Type) extends UncachedProxyType with ValueType
Companion
object
object LazyRef
Companion
class
class MatchAlias(alias: Type) extends AliasingBounds

= T where T is a MatchType

= T where T is a MatchType

Match aliases are treated differently from type aliases. Their sides are mutually subtypes of each other but one side is not generally substitutable for the other. If we assumed full substitutivity, we would have to reject all recursive match aliases (or else take the jump and allow full recursive types).

Companion
object
object MatchAlias
Companion
class
abstract case class MatchType(bound: Type, scrutinee: Type, cases: List[Type]) extends CachedProxyType with ValueType

scrutinee match { case_1 ... case_n }

scrutinee match { case_1 ... case_n }

where

case_i = [X1, ..., Xn] patternType => resultType

and X_1,...X_n are the type variables bound in patternType

Companion
object
object MatchType
Companion
class
sealed abstract class MethodOrPoly extends UncachedGroundType with LambdaType with MethodicType

The superclass of MethodType and PolyType.

The superclass of MethodType and PolyType.

object MethodTpe

A ternary extractor for MethodType

A ternary extractor for MethodType

abstract case class MethodType(paramNames: List[TermName])(paramInfosExp: MethodType => List[Type], resultTypeExp: MethodType => Type) extends MethodOrPoly with TermLambda with NarrowCached
Companion
object
Companion
class
abstract class MethodTypeCompanion(val prefixString: String) extends TermLambdaCompanion[MethodType]
trait MethodicType extends TermType
abstract class NameFilter

A name filter selects or discards a member name of a type pre. To enable efficient caching, name filters have to satisfy the following invariant: If keep is a name filter, and pre has class C as a base class, then

A name filter selects or discards a member name of a type pre. To enable efficient caching, name filters have to satisfy the following invariant: If keep is a name filter, and pre has class C as a base class, then

keep(pre, name) implies keep(C.this, name)

abstract class NamedType extends CachedProxyType with ValueType
Companion
object
object NamedType
Companion
class
trait NarrowCached extends Type

Implementations of this trait cache the results of narrow.

Implementations of this trait cache the results of narrow.

case object NoPrefix extends CachedGroundType

Missing prefix

Missing prefix

case object NoType extends CachedGroundType

Sentinel for "missing type"

Sentinel for "missing type"

object OrNull

An extractor object to pattern match against a nullable union. e.g.

An extractor object to pattern match against a nullable union. e.g.

(tp: Type) match case OrNull(tp1) => // tp had the form tp1 | Null case _ => // tp was not a nullable union

abstract case class OrType(tp1: Type, tp2: Type) extends AndOrType
Companion
object
object OrType
Companion
class
abstract class ParamRef extends BoundType
class PolyType(val paramNames: List[TypeName])(paramInfosExp: PolyType => List[TypeBounds], resultTypeExp: PolyType => Type) extends MethodOrPoly with TypeLambda

The type of a polymorphic method. It has the same form as HKTypeLambda, except it applies to terms and parameters do not have variances.

The type of a polymorphic method. It has the same form as HKTypeLambda, except it applies to terms and parameters do not have variances.

Companion
object
Companion
class
trait ProtoType extends Type

A trait for proto-types, used as expected types in typer

A trait for proto-types, used as expected types in typer

class QualSkolemType(info: Type) extends SkolemType

A skolem type used to wrap the type of the qualifier of a selection.

A skolem type used to wrap the type of the qualifier of a selection.

When typing a selection e.f, if e is unstable then we unconditionally skolemize it. We use a subclass of SkolemType for this so that TypeOps#asSeenFrom may treat it specially for optimization purposes, see its implementation for more details.

Companion
object
Companion
class
class RealTypeBounds(lo: Type, hi: Type) extends TypeBounds
abstract case class RecThis(binder: RecType) extends BoundType with SingletonType

a self-reference to an enclosing recursive type. The only creation method is binder.recThis, returning RecThis(binder).

a self-reference to an enclosing recursive type. The only creation method is binder.recThis, returning RecThis(binder).

class RecType(parentExp: RecType => Type) extends RefinedOrRecType with BindingType

A recursive type. Instances should be constructed via the companion object.

A recursive type. Instances should be constructed via the companion object.

Value Params
parentExp

A function that, given a recursive type R, produces a type that can refer to R via a RecThis(R) node. This is used to "tie the knot". For example, in class C { type T1; type T2 } type C2 = C { type T1; type T2 = T1 } The type of C2 is a recursive type {(x) => C{T1; T2 = x.T1}}, written as RecType( RefinedType( RefinedType( TypeRef(...,class C), T1, TypeBounds(...)), T2, TypeBounds( TypeRef(RecThis(...),T1), TypeRef(RecThis(...),T1)))) Where RecThis(...) points back to the enclosing RecType.

Companion
object
object RecType
Companion
class
abstract class RefinedOrRecType extends CachedProxyType with ValueType
abstract case class RefinedType(parent: Type, refinedName: Name, refinedInfo: Type) extends RefinedOrRecType

A refined type parent { refinement }

A refined type parent { refinement }

Value Params
parent

The type being refined

refinedInfo

The info of the refinement declaration

refinedName

The name of the refinement declaration

Companion
object
object RefinedType
Companion
class
object SAMType

An extractor for single abstract method types. A type is a SAM type if it is a reference to a class or trait, which

An extractor for single abstract method types. A type is a SAM type if it is a reference to a class or trait, which

  • has a single abstract method with a method type (ExprType and PolyType not allowed!) whose result type is not an implicit function type
  • can be instantiated without arguments or with just () as argument.

The pattern SAMType(sam) matches a SAM type, where sam is the type of the single abstract method.

trait SingletonType extends TypeProxy with ValueType

A marker trait for types that are guaranteed to contain only a single non-null value (they might contain null in addition).

A marker trait for types that are guaranteed to contain only a single non-null value (they might contain null in addition).

case class SkolemType(info: Type) extends UncachedProxyType with ValueType with SingletonType

A skolem type reference with underlying type info.

A skolem type reference with underlying type info.

For Dotty, a skolem type is a singleton type of some unknown value of type info. Note that care is needed when creating them, since not all types need to be inhabited. A skolem is equal to itself and no other type.

abstract case class SuperType(thistpe: Type, supertpe: Type) extends CachedProxyType with SingletonType

The type of a super reference cls.super where thistpe is cls.this and supertpe is the type of the value referenced by super.

The type of a super reference cls.super where thistpe is cls.this and supertpe is the type of the value referenced by super.

Companion
object
object SuperType
Companion
class
final class TempClassInfo(prefix: Type, cls: ClassSymbol, decls: Scope, selfInfo: TypeOrSymbol) extends CachedClassInfo

A class for temporary class infos where parents are not yet known

A class for temporary class infos where parents are not yet known

trait TermLambda extends LambdaType
abstract case class TermParamRef(binder: TermLambda, paramNum: Int) extends ParamRef with SingletonType

Only created in binder.paramRefs. Use binder.paramRefs(paramNum) to refer to TermParamRef(binder, paramNum).

Only created in binder.paramRefs. Use binder.paramRefs(paramNum) to refer to TermParamRef(binder, paramNum).

abstract case class TermRef(prefix: Type, var myDesignator: Designator) extends NamedType with SingletonType with ImplicitRef

The singleton type for path prefix#myDesignator.

The singleton type for path prefix#myDesignator.

Companion
object
object TermRef
Companion
class
trait TermType extends Type

A marker trait for types that apply only to term symbols or that represent higher-kinded types.

A marker trait for types that apply only to term symbols or that represent higher-kinded types.

abstract case class ThisType(tref: TypeRef) extends CachedProxyType with SingletonType

The type cls.this

The type cls.this

Value Params
tref

A type ref which indicates the class cls. Note: we do not pass a class symbol directly, because symbols do not survive runs whereas typerefs do.

Companion
object
object ThisType
Companion
class
abstract class Type extends Hashable with Showable

Main class representing types.

Main class representing types.

The principal subclasses and sub-objects are as follows:

Type -+- ProxyType --+- NamedType ----+--- TypeRef
      |              |                 \
      |              +- SingletonType-+-+- TermRef
      |              |                |
      |              |                +--- ThisType
      |              |                +--- SuperType
      |              |                +--- ConstantType
      |              |                +--- TermParamRef
      |              |                +----RecThis
      |              |                +--- SkolemType
      |              +- TypeParamRef
      |              +- RefinedOrRecType -+-- RefinedType
      |              |                   -+-- RecType
      |              +- AppliedType
      |              +- TypeBounds
      |              +- ExprType
      |              +- AnnotatedType
      |              +- TypeVar
      |              +- HKTypeLambda
      |              +- MatchType
      |
      +- GroundType -+- AndType
                     +- OrType
                     +- MethodOrPoly ---+-- PolyType
                     |                  +-- MethodType
                     +- ClassInfo
                     |
                     +- NoType
                     +- NoPrefix
                     +- ErrorType
                     +- WildcardType

Note: please keep in sync with copy in docs/docs/internals/type-system.md.

abstract class TypeAccumulator[T](implicit val accCtx: Context) extends VariantTraversal with (T, Type) => T
class TypeAlias(alias: Type) extends AliasingBounds

= T

= T

Companion
object
object TypeAlias
Companion
class
abstract case class TypeBounds(lo: Type, hi: Type) extends CachedProxyType with TypeType

Type bounds >: lo <: hi

Type bounds >: lo <: hi

Companion
object
object TypeBounds
Companion
class
trait TypeLambda extends LambdaType
abstract class TypeMap(implicit var mapCtx: Context) extends VariantTraversal with Type => Type
abstract case class TypeParamRef(binder: TypeLambda, paramNum: Int) extends ParamRef

Only created in binder.paramRefs. Use binder.paramRefs(paramNum) to refer to TypeParamRef(binder, paramNum).

Only created in binder.paramRefs. Use binder.paramRefs(paramNum) to refer to TypeParamRef(binder, paramNum).

abstract class TypeProxy extends Type

A marker trait for type proxies. Each implementation is expected to redefine the underlying method.

A marker trait for type proxies. Each implementation is expected to redefine the underlying method.

abstract case class TypeRef(prefix: Type, var myDesignator: Designator) extends NamedType
Companion
object
object TypeRef
Companion
class
class TypeSizeAccumulator(using `x$1`: Context) extends TypeAccumulator[Int]
abstract class TypeTraverser(using `x$1`: Context) extends TypeAccumulator[Unit]
trait TypeType extends Type

A marker trait for types that apply only to type symbols

A marker trait for types that apply only to type symbols

final class TypeVar extends CachedProxyType with ValueType

In a TypeApply tree, a TypeVar is created for each argument type to be inferred. Every type variable is referred to by exactly one inferred type parameter of some TypeApply tree.

In a TypeApply tree, a TypeVar is created for each argument type to be inferred. Every type variable is referred to by exactly one inferred type parameter of some TypeApply tree.

A type variable is essentially a switch that models some part of a substitution. It is first linked to origin, a poly param that's in the current constraint set. It can then be (once) instantiated to some other type. The instantiation is recorded in the type variable itself, or else, if the current type state is different from the variable's creation state (meaning unrolls are possible) in the current typer state.

Value Params
creatorState

The typer state in which the variable was created.

origin

The parameter that's tracked by the type variable.

Companion
object
object TypeVar
Companion
class
abstract class UncachedGroundType extends Type

Instances of this class are uncached and are not proxies.

Instances of this class are uncached and are not proxies.

abstract class UncachedProxyType extends TypeProxy

Instances of this class are uncached and are proxies.

Instances of this class are uncached and are proxies.

A marker trait for types that can be types of values or that are higher-kinded

A marker trait for types that can be types of values or that are higher-kinded

trait ValueTypeOrProto extends TermType

A marker trait for types that can be types of values or prototypes of value types

A marker trait for types that can be types of values or prototypes of value types

abstract class VariantTraversal

Common base class of TypeMap and TypeAccumulator

Common base class of TypeMap and TypeAccumulator

abstract case class WildcardType(optBounds: Type) extends CachedGroundType with TermType

Wildcard type, possibly with bounds

Wildcard type, possibly with bounds

Companion
object
object WildcardType extends WildcardType
Companion
class

A filter for names of deferred term definitions of a given type

A filter for names of deferred term definitions of a given type

A filter for names of abstract types of a given type

A filter for names of abstract types of a given type

object fieldFilter extends NameFilter
object implicitFilter extends NameFilter
class isGroundAccumulator(using `x$1`: Context) extends TypeAccumulator[Boolean]

A filter for names of abstract types of a given type

A filter for names of abstract types of a given type

object takeAllFilter extends NameFilter

A filter for names of type aliases of a given type

A filter for names of type aliases of a given type

object typeNameFilter extends NameFilter

Value members

Concrete methods

def isWatched(tp: Type)(using Context): Boolean

Concrete fields

Extensions

Extensions

Implicits

Implicits

implicit def eqType: CanEqual[Type, Type]