Type

dotty.tools.dotc.core.Types$.Type
abstract class Type extends Hashable with Showable

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.

Attributes

Graph
Supertypes
trait Showable
trait Hashable
class Object
trait Matchable
class Any
Known subtypes
class HKLambda
class PolyType
class RecType
class AndOrType
class AndType
class OrType
class ClassInfo
object NoPrefix.type
object NoType.type
object WildcardType.type
class ViewProto
class BoundType
class ParamRef
class RecThis
class ExprType
class MatchType
class NamedType
class TermRef
class TypeRef
class SuperType
class ThisType
class TypeAlias
class TypeVar
object AnySelectionProto.type
trait ProtoType
class FunProto
class PolyProto
object AnyFunctionProto.type
object AssignProto.type
trait TermType
trait ValueType
class FlexType
class ErrorType
object TryDynamicCallType.type
class LazyRef
class TypeProxy
trait TypeType
class LazyType
class NoLoader
object NoCompleter.type
class StubInfo
class Completer
class Completer
class Range

Members list

Concise view

Value members

Abstract methods

Compute hashcode relative to enclosing binders bs

Compute hashcode relative to enclosing binders bs

Attributes

def hash: Int

customized hash code of this type. NotCached for uncached types. Cached types compute hash and use it as the type's hashCode.

customized hash code of this type. NotCached for uncached types. Cached types compute hash and use it as the type's hashCode.

Attributes

Concrete methods

def &(that: Type)(using Context): Type
final def <:<(that: Type)(using Context): Boolean

Is this type a subtype of that type?

Is this type a subtype of that type?

Attributes

final def =:=(that: Type)(using Context): Boolean

Is this type the same as that type? This is the case iff this <:< that and that <:< this.

Is this type the same as that type? This is the case iff this <:< that and that <:< this.

Attributes

def EtaExpand(tparams: List[TypeParamInfo])(using Context): Type
Implicitly added by decorateTypeApplications

Convert a type constructor TC which has type parameters X1, ..., Xn to [X1, ..., Xn] -> TC[X1, ..., Xn].

Convert a type constructor TC which has type parameters X1, ..., Xn to [X1, ..., Xn] -> TC[X1, ..., Xn].

Attributes

def EtaExpandIfHK(bound: Type)(using Context): Type
Implicitly added by decorateTypeApplications

Eta expand if self is a (non-lambda) class reference and bound is a higher-kinded type

Eta expand if self is a (non-lambda) class reference and bound is a higher-kinded type

Attributes

The set of abstract term members of this type.

The set of abstract term members of this type.

Attributes

The set of abstract type members of this type.

The set of abstract type members of this type.

Attributes

All members of this type. Warning: this can be expensive to compute!

All members of this type. Warning: this can be expensive to compute!

Attributes

If this is an AndType, the number of factors, 1 for all other types

If this is an AndType, the number of factors, 1 for all other types

Attributes

final def appliedTo(args: List[Type])(using Context): Type
Implicitly added by decorateTypeApplications

The type representing

The type representing

T[U1, ..., Un]

where

Attributes

args

= U1,...,Un

self

= T

final def appliedTo(arg: Type)(using Context): Type
Implicitly added by decorateTypeApplications
final def appliedTo(arg1: Type, arg2: Type)(using Context): Type
Implicitly added by decorateTypeApplications
final def applyIfParameterized(args: List[Type])(using Context): Type
Implicitly added by decorateTypeApplications
final def argInfo(using Context): Type
Implicitly added by decorateTypeApplications

If this is the image of a type argument; recover the type argument, otherwise NoType.

If this is the image of a type argument; recover the type argument, otherwise NoType.

Attributes

final def argInfos(using Context): List[Type]
Implicitly added by decorateTypeApplications

If this is an encoding of a (partially) applied type, return its arguments, otherwise return Nil. Existential types in arguments are returned as TypeBounds instances.

If this is an encoding of a (partially) applied type, return its arguments, otherwise return Nil. Existential types in arguments are returned as TypeBounds instances.

Attributes

def argTypes(using Context): List[Type]
Implicitly added by decorateTypeApplications

Argument types where existential types in arguments are disallowed

Argument types where existential types in arguments are disallowed

Attributes

Implicitly added by decorateTypeApplications

Argument types where existential types in arguments are approximated by their upper bound

Argument types where existential types in arguments are approximated by their upper bound

Attributes

Implicitly added by decorateTypeApplications

Argument types where existential types in arguments are approximated by their lower bound

Argument types where existential types in arguments are approximated by their lower bound

Attributes

final def asSeenFrom(pre: Type, cls: Symbol)(using Context): Type

This type seen as if it were the type of a member of prefix type pre declared in class cls.

This type seen as if it were the type of a member of prefix type pre declared in class cls.

Attributes

def atoms(using Context): Atoms

The singleton types that must or may be in this type. @see Atoms. Overridden and cached in OrType.

The singleton types that must or may be in this type. @see Atoms. Overridden and cached in OrType.

Attributes

The base classes of this type as determined by ClassDenotation in linearization order, with the class itself as first element. Inherited by all type proxies. Overridden for And and Or types. Nil for all other types.

The base classes of this type as determined by ClassDenotation in linearization order, with the class itself as first element. Inherited by all type proxies. Overridden for And and Or types. Nil for all other types.

Attributes

final def baseType(base: Symbol)(using Context): Type

The basetype of this type with given class symbol, NoType if base is not a class.

The basetype of this type with given class symbol, NoType if base is not a class.

Attributes

final def bounds(using Context): TypeBounds

This type seen as a TypeBounds

This type seen as a TypeBounds

Attributes

The capture set of this type. Overridden and cached in CaptureRef

The capture set of this type. Overridden and cached in CaptureRef

Attributes

def capturing(ref: CaptureRef)(using Context): Type

A type capturing ref

A type capturing ref

Attributes

def capturing(cs: CaptureSet)(using Context): Type

A type capturing the capture set cs. If this type is already a capturing type the two capture sets are combined.

A type capturing the capture set cs. If this type is already a capturing type the two capture sets are combined.

Attributes

final def classSymbol(using Context): Symbol

The least class or trait of which this type is a subtype or parameterized instance, or NoSymbol if none exists (either because this type is not a value type, or because superclasses are ambiguous).

The least class or trait of which this type is a subtype or parameterized instance, or NoSymbol if none exists (either because this type is not a value type, or because superclasses are ambiguous).

Attributes

The least (wrt <:<) set of class symbols of which this type is a subtype

The least (wrt <:<) set of class symbols of which this type is a subtype

Attributes

Does this type contain wildcard types?

Does this type contain wildcard types?

Attributes

The set of distinct symbols referred to by this type, after all aliases are expanded

The set of distinct symbols referred to by this type, after all aliases are expanded

Attributes

final def dealias(using Context): Type

Follow aliases and dereferences LazyRefs, annotated types and instantiated TypeVars until type is no longer alias type, annotated type, LazyRef, or instantiated type variable.

Follow aliases and dereferences LazyRefs, annotated types and instantiated TypeVars until type is no longer alias type, annotated type, LazyRef, or instantiated type variable.

Attributes

final def dealiasKeepAnnots(using Context): Type

Follow aliases and dereferences LazyRefs and instantiated TypeVars until type is no longer alias type, LazyRef, or instantiated type variable. Goes through annotated types and rewraps annotations on the result.

Follow aliases and dereferences LazyRefs and instantiated TypeVars until type is no longer alias type, LazyRef, or instantiated type variable. Goes through annotated types and rewraps annotations on the result.

Attributes

final def dealiasKeepOpaques(using Context): Type

Follow non-opaque aliases and dereferences LazyRefs, annotated types and instantiated TypeVars until type is no longer alias type, annotated type, LazyRef, or instantiated type variable.

Follow non-opaque aliases and dereferences LazyRefs, annotated types and instantiated TypeVars until type is no longer alias type, annotated type, LazyRef, or instantiated type variable.

Attributes

Like dealiasKeepAnnots, but keeps only refining annotations

Like dealiasKeepAnnots, but keeps only refining annotations

Attributes

final def decl(name: Name)(using Context): Denotation

A denotation containing the declaration(s) in this type with the given name. The result is either a SymDenotation or a MultiDenotation of SymDenotations. The info(s) are the original symbol infos, no translation takes place.

A denotation containing the declaration(s) in this type with the given name. The result is either a SymDenotation or a MultiDenotation of SymDenotations. The info(s) are the original symbol infos, no translation takes place.

Attributes

final def decls(using Context): Scope

The scope of all declarations of this type. Defined by ClassInfo, inherited by type proxies. Empty scope for all other types.

The scope of all declarations of this type. Defined by ClassInfo, inherited by type proxies. Empty scope for all other types.

Attributes

final def deconst(using Context): Type

Widen from constant type to its underlying non-constant base type.

Widen from constant type to its underlying non-constant base type.

Attributes

If this is a prototype with some ignored component, reveal one more layer of it. Otherwise the type itself.

If this is a prototype with some ignored component, reveal one more layer of it. Otherwise the type itself.

Attributes

If this is a prototype with some ignored component, reveal it, and deepen the result transitively. Otherwise the type itself.

If this is a prototype with some ignored component, reveal it, and deepen the result transitively. Otherwise the type itself.

Attributes

Does this type have a supertype with an annotation satisfying given predicate p?

Does this type have a supertype with an annotation satisfying given predicate p?

Attributes

final def derivesFrom(cls: Symbol)(using Context): Boolean

True if this type is an instance of the given cls or an instance of a non-bottom subclass of cls.

True if this type is an instance of the given cls or an instance of a non-bottom subclass of cls.

Attributes

final def deskolemized(using Context): Type

Approximate this type with a type that does not contain skolem types.

Approximate this type with a type that does not contain skolem types.

Attributes

def dropAlias(using Context): Type
Implicitly added by decorateTypeApplications

If this is a type alias, its underlying type, otherwise the type itself

If this is a type alias, its underlying type, otherwise the type itself

Attributes

def dropAnnot(cls: Symbol)(using Context): Type

Drop annotation of given cls from this type

Drop annotation of given cls from this type

Attributes

Dealias, and if result is a dependent function type, drop the apply refinement.

Dealias, and if result is a dependent function type, drop the apply refinement.

Attributes

If this is a proto type, WildcardType, otherwise the type itself

If this is a proto type, WildcardType, otherwise the type itself

Attributes

def elemType(using Context): Type
Implicitly added by decorateTypeApplications

The element type of a sequence or array

The element type of a sequence or array

Attributes

Implicitly added by decorateTypeApplications

If self is not lambda-bound, eta expand it.

If self is not lambda-bound, eta expand it.

Attributes

def eql(that: Type): Boolean

Equality used for hash-consing; uses eq on all recursive invocations, except where a BindingType is involved. The latter demand a deep isomorphism check.

Equality used for hash-consing; uses eq on all recursive invocations, except where a BindingType is involved. The latter demand a deep isomorphism check.

Attributes

final def equals(that: Any, bs: BinderPairs): Boolean

Compare this == that, assuming corresponding binders in bs are equal. The normal equals should be equivalent to equals(that, null). We usually overrideequalswhen we overrideisoexcept if theequals` comes from a case class, so it already has the right definition anyway.

Compare this == that, assuming corresponding binders in bs are equal. The normal equals should be equivalent to equals(that, null). We usually overrideequalswhen we overrideisoexcept if theequals` comes from a case class, so it already has the right definition anyway.

Attributes

final def exists: Boolean

Is this type different from NoType?

Is this type different from NoType?

Attributes

final def existsPart(p: Type => Boolean, stopAt: StopAt, forceLazy: Boolean)(using Context): Boolean

Returns true if there is a part of this type that satisfies predicate p.

Returns true if there is a part of this type that satisfies predicate p.

Attributes

final def fields(using Context): Seq[SingleDenotation]

The final result type of a PolyType, MethodType, or ExprType, after skipping all parameter sections, the type itself for all others.

The final result type of a PolyType, MethodType, or ExprType, after skipping all parameter sections, the type itself for all others.

Attributes

final def findDecl(name: Name, excluded: FlagSet)(using Context): Denotation

A denotation containing the declaration(s) in this type with the given name, as seen from prefix type pre. Declarations that have a flag in excluded are omitted.

A denotation containing the declaration(s) in this type with the given name, as seen from prefix type pre. Declarations that have a flag in excluded are omitted.

Attributes

Determine the expected function type from the prototype. If no function type is found, NoType is returned. If multiple function types are found in an intersection, their intersection is returned. This works since & invokes TypeComparer.distributeAnd, which ensures that (A1 => B1) & (A2 => B2) simplifies to (A1 | A2) => (B1 & B2), so the result is again a function type. An analogous distribution mechanism does not exist for |. Therefore, a union of function types also yields NoType, since we cannot determine a single expected function type.

Determine the expected function type from the prototype. If no function type is found, NoType is returned. If multiple function types are found in an intersection, their intersection is returned. This works since & invokes TypeComparer.distributeAnd, which ensures that (A1 => B1) & (A2 => B2) simplifies to (A1 | A2) => (B1 & B2), so the result is again a function type. An analogous distribution mechanism does not exist for |. Therefore, a union of function types also yields NoType, since we cannot determine a single expected function type.

Attributes

final def findMember(name: Name, pre: Type, required: FlagSet, excluded: FlagSet)(using Context): Denotation

Find member of this type with given name, all required flags and no excluded flag and produce a denotation that contains the type of the member as seen from given prefix pre.

Find member of this type with given name, all required flags and no excluded flag and produce a denotation that contains the type of the member as seen from given prefix pre.

Attributes

The parameter names in the first parameter section of a generic type or MethodType, Empty list for others

The parameter names in the first parameter section of a generic type or MethodType, Empty list for others

Attributes

final def firstParamTypes(using Context): List[Type]

The parameter types in the first parameter section of a generic type or MethodType, Empty list for others

The parameter types in the first parameter section of a generic type or MethodType, Empty list for others

Attributes

The first parent of this type, AnyRef if list of parents is empty

The first parent of this type, AnyRef if list of parents is empty

Attributes

final def forallParts(p: Type => Boolean)(using Context): Boolean

Returns true if all parts of this type satisfy predicate p.

Returns true if all parts of this type satisfy predicate p.

Attributes

final def foreachPart(p: Type => Unit, stopAt: StopAt)(using Context): Unit

Performs operation on all parts of this type

Performs operation on all parts of this type

Attributes

final def frozen_<:<(that: Type)(using Context): Boolean

Is this type a subtype of that type?

Is this type a subtype of that type?

Attributes

final def frozen_=:=(that: Type)(using Context): Boolean
final def hasAnnotation(cls: ClassSymbol)(using Context): Boolean

Does the type carry an annotation that is an instance of cls?

Does the type carry an annotation that is an instance of cls?

Attributes

Is this type of kind AnyKind?

Is this type of kind AnyKind?

Attributes

final def hasClassSymbol(cls: Symbol)(using Context): Boolean

Same as this.classSymbols.contains(cls) but more efficient

Same as this.classSymbols.contains(cls) but more efficient

Attributes

def hasSameKindAs(other: Type)(using Context): Boolean
Implicitly added by decorateTypeApplications

Do self and other have the same kinds (not counting bounds and variances)? Note: An any-kinded type "has the same kind" as any other type.

Do self and other have the same kinds (not counting bounds and variances)? Note: An any-kinded type "has the same kind" as any other type.

Attributes

Implicitly added by decorateTypeApplications

Is self type of kind "*"?

Is self type of kind "*"?

Attributes

Is the hash of this type the same for all possible sequences of enclosing binders?

Is the hash of this type the same for all possible sequences of enclosing binders?

Attributes

The upper bound of a TypeBounds type, the type itself otherwise

The upper bound of a TypeBounds type, the type itself otherwise

Attributes

def hkResult(using Context): Type
Implicitly added by decorateTypeApplications

If self type is higher-kinded, its result type, otherwise NoType. Note: The hkResult of an any-kinded type is again AnyKind.

If self type is higher-kinded, its result type, otherwise NoType. Note: The hkResult of an any-kinded type is again AnyKind.

Attributes

Implicitly added by decorateTypeApplications

If self is a higher-kinded type, its type parameters, otherwise Nil

If self is a higher-kinded type, its type parameters, otherwise Nil

Attributes

final def implicitMembers(using Context): List[TermRef]

The set of implicit term members of this type

The set of implicit term members of this type

Attributes

def isAny(using Context): Boolean

True iff symd is a denotation of a class type parameter and the reference `

True iff symd is a denotation of a class type parameter and the reference `

 . ` is an actual argument reference, i.e. `pre` is not the
ThisType of `symd`'s owner, or a reference to `symd`'s owner.'

Attributes

Is this a Method or PolyType which has contextual parameters as first value parameter list?

Is this a Method or PolyType which has contextual parameters as first value parameter list?

Attributes

Is this a higher-kinded type lambda with given parameter variances?

Is this a higher-kinded type lambda with given parameter variances?

Attributes

def isDirectRef(sym: Symbol)(using Context): Boolean

Is this type a (neither aliased nor applied nor annotated) reference to class sym?

Is this type a (neither aliased nor applied nor annotated) reference to class sym?

Attributes

Is this a MethodType for which the parameters will not be used?

Is this a MethodType for which the parameters will not be used?

Attributes

Is some part of the widened version of this type produced as a repair for an error?

Is some part of the widened version of this type produced as a repair for an error?

Attributes

final def isError(using Context): Boolean

Is this type produced as a repair for an error?

Is this type produced as a repair for an error?

Attributes

Is this type exactly Any (no vars, aliases, refinements etc allowed)?

Is this type exactly Any (no vars, aliases, refinements etc allowed)?

Attributes

Is this type exactly Nothing (no vars, aliases, refinements etc allowed)?

Is this type exactly Nothing (no vars, aliases, refinements etc allowed)?

Attributes

Is this type exactly Null (no vars, aliases, refinements etc allowed)?

Is this type exactly Null (no vars, aliases, refinements etc allowed)?

Attributes

final def isGround(using Context): Boolean

Does this type not refer to TypeParamRefs or uninstantiated TypeVars?

Does this type not refer to TypeParamRefs or uninstantiated TypeVars?

Attributes

Is this a Method or PolyType which has implicit or contextual parameters?

Is this a Method or PolyType which has implicit or contextual parameters?

Attributes

Implicitly added by decorateTypeApplications

Is self type bounded by a type lambda or AnyKind?

Is self type bounded by a type lambda or AnyKind?

Attributes

def isMatch(using Context): Boolean

Is this a match type or a higher-kinded abstraction of one?

Is this a match type or a higher-kinded abstraction of one?

Attributes

Same as hasClassSmbol(MatchableClass), except that we also follow the constraint bounds of type variables in the constraint.

Same as hasClassSmbol(MatchableClass), except that we also follow the constraint bounds of type variables in the constraint.

Attributes

final def isNotNull(using Context): Boolean

Is this type guaranteed not to have null as a value?

Is this type guaranteed not to have null as a value?

Attributes

final def isNothingType(using Context): Boolean

Is this (an alias of) the scala.Nothing type?

Is this (an alias of) the scala.Nothing type?

Attributes

final def isNullType(using Context): Boolean

Is this (an alias of) the scala.Null type?

Is this (an alias of) the scala.Null type?

Attributes

Is this the type of a method with a leading empty parameter list?

Is this the type of a method with a leading empty parameter list?

Attributes

final def isParameterless(using Context): Boolean

Is this either not a method at all, or a parameterless method?

Is this either not a method at all, or a parameterless method?

Attributes

Is this type still provisional? This is the case if the type contains, or depends on, uninstantiated type variables or type symbols that have the Provisional flag set. This is an antimonotonic property - once a type is not provisional, it stays so forever.

Is this type still provisional? This is the case if the type contains, or depends on, uninstantiated type variables or type symbols that have the Provisional flag set. This is an antimonotonic property - once a type is not provisional, it stays so forever.

Attributes

def isRef(sym: Symbol, skipRefined: Boolean)(using Context): Boolean

Is this type a (possibly refined, applied, aliased or annotated) type reference to the given type symbol?

Is this type a (possibly refined, applied, aliased or annotated) type reference to the given type symbol?

Attributes

Is this a type of a repeated parameter?

Is this a type of a repeated parameter?

Attributes

Is this type a (possibly aliased) singleton type?

Is this type a (possibly aliased) singleton type?

Attributes

final def isStable(using Context): Boolean

Does this type denote a stable reference (i.e. singleton type)?

Does this type denote a stable reference (i.e. singleton type)?

Like in isStableMember, "stability" means idempotence. Rationale: If an expression has a stable type, the expression must be idempotent, so stable types must be singleton types of stable expressions.

Attributes

final def isTypeAlias: Boolean

Is this an alias TypeBounds?

Is this an alias TypeBounds?

Attributes

def isValueSubType(that: Type)(using Context): Boolean

Is this type a primitive value type which can be widened to the primitive value type that?

Is this type a primitive value type which can be widened to the primitive value type that?

Attributes

final def isValueType: Boolean

Is this type a value type?

Is this type a value type?

Attributes

Is this a value type or a type lambda?

Is this a value type or a type lambda?

Attributes

Is this a value type or a wildcard?

Is this a value type or a wildcard?

Attributes

Is this the type of a method that has a repeated parameter type as last parameter type?

Is this the type of a method that has a repeated parameter type as last parameter type?

Attributes

protected def iso(that: Any, bs: BinderPairs): Boolean

Is this isomorphic to that, assuming pairs of matching binders bs? It is assumed that this.ne(that).

Is this isomorphic to that, assuming pairs of matching binders bs? It is assumed that this.ne(that).

Attributes

The lower bound of a TypeBounds type, the type itself otherwise

The lower bound of a TypeBounds type, the type itself otherwise

Attributes

def lookupRefined(name: Name)(using Context): Type

If this normalizes* to a refinement type that has a refinement for name (which might be followed by other refinements), and the refined info is a type alias, return the alias, otherwise return NoType. Used to reduce types of the form

If this normalizes* to a refinement type that has a refinement for name (which might be followed by other refinements), and the refined info is a type alias, return the alias, otherwise return NoType. Used to reduce types of the form

P { ... type T = / += / -= U ... } # T

to just U. Does not perform the reduction if the resulting type would contain a reference to the "this" of the current refined type, except in the following situation

(1) The "this" reference can be avoided by following an alias. Example:

P { type T = String, type R = P{...}.T } # R  -->  String

(*) normalizes means: follow instantiated typevars and aliases.

Attributes

def mapReduceAnd[T](f: Type => T)(g: (T, T) => T)(using Context): T

Map function f over elements of an AndType, rebuilding with function g

Map function f over elements of an AndType, rebuilding with function g

Attributes

final def mapReduceOr[T](f: Type => T)(g: (T, T) => T)(using Context): T

Map function f over elements of an OrType, rebuilding with function g

Map function f over elements of an OrType, rebuilding with function g

Attributes

def matches(that: Type)(using Context): Boolean

Is this type close enough to that type so that members with the two types would override each other? This means:

Is this type close enough to that type so that members with the two types would override each other? This means:

  • Either both types are polytypes with the same number of type parameters and their result types match after renaming corresponding type parameters
  • Or both types are method types with =:=-equivalent(*) parameter types and matching result types after renaming corresponding parameter types if the method types are dependent.
  • Or both types are =:=-equivalent
  • Or phase.erasedTypes is false, and neither type takes term or type parameters.

(*) when matching with a Java method, we also regard Any and Object as equivalent parameter types.

Under explicit nulls, this function will always use unsafe-nulls semamtics to check the types. This is because we are using a relaxed rule (ignoring Null types) to check overriding Java methods.

Attributes

def matchesLoosely(that: Type)(using Context): Boolean

This is the same as matches except that it also matches => T with T and vice versa.

This is the same as matches except that it also matches => T with T and vice versa.

Attributes

final def member(name: Name)(using Context): Denotation

The member of this type with the given name

The member of this type with the given name

Attributes

final def memberBasedOnFlags(name: Name, required: FlagSet, excluded: FlagSet)(using Context): Denotation

The member with given name and required and/or excluded flags

The member with given name and required and/or excluded flags

Attributes

The set of member classes of this type

The set of member classes of this type

Attributes

final def memberInfo(sym: Symbol)(using Context): Type

The info of sym, seen as a member of this type.

The info of sym, seen as a member of this type.

Attributes

final def memberNames(keepOnly: NameFilter, pre: Type)(using Context): Set[Name]

The set of names of members of this type that pass the given name filter when seen as members of pre. More precisely, these are all of members name such that keepOnly(pre, name) is true.

The set of names of members of this type that pass the given name filter when seen as members of pre. More precisely, these are all of members name such that keepOnly(pre, name) is true.

Attributes

final def membersBasedOnFlags(required: FlagSet, excluded: FlagSet)(using Context): Seq[SingleDenotation]

The set of members of this type that have all of required flags but none of excluded flags set.

The set of members of this type that have all of required flags but none of excluded flags set.

Attributes

The parts of this type which are type or term refs and which satisfy predicate p.

The parts of this type which are type or term refs and which satisfy predicate p.

Attributes

p

The predicate to satisfy

def narrow(using Context): TermRef

A prefix-less refined this or a termRef to a new skolem symbol that has the given type as info.

A prefix-less refined this or a termRef to a new skolem symbol that has the given type as info.

Attributes

The set of abstract type members of this type.

The set of abstract type members of this type.

Attributes

final def nonPrivateDecl(name: Name)(using Context): Denotation

A denotation containing the non-private declaration(s) in this type with the given name

A denotation containing the non-private declaration(s) in this type with the given name

Attributes

final def nonPrivateMember(name: Name)(using Context): Denotation

The non-private member of this type with the given name.

The non-private member of this type with the given name.

Attributes

final def normalized(using Context): Type

The result of normalization using tryNormalize, or the type itself if tryNormlize yields NoType

The result of normalization using tryNormalize, or the type itself if tryNormlize yields NoType

Attributes

final def normalizedPrefix(using Context): Type

The normalized prefix of this type is: For an alias type, the normalized prefix of its alias For all other named type and class infos: the prefix. Inherited by all other type proxies. NoType for all other types.

The normalized prefix of this type is: For an alias type, the normalized prefix of its alias For all other named type and class infos: the prefix. Inherited by all other type proxies. NoType for all other types.

Attributes

def occursIn(that: Type)(using Context): Boolean

Does this type occur as a part of type that?

Does this type occur as a part of type that?

Attributes

inline def orElse(inline that: Type): Type

This type, if it exists, otherwise that type

This type, if it exists, otherwise that type

Attributes

If this is a OrType, the number of factors if that match soft, 1 for all other types.

If this is a OrType, the number of factors if that match soft, 1 for all other types.

Attributes

final def overrides(that: Type, relaxedCheck: Boolean, matchLoosely: => Boolean, checkClassInfo: Boolean)(using Context): Boolean

Is this type a legal type for member sym1 that overrides another member sym2 of type that? This is the same as <:<, except that

Is this type a legal type for member sym1 that overrides another member sym2 of type that? This is the same as <:<, except that

Attributes

checkClassInfo

if true we check that ClassInfos are within bounds of abstract types

matchLoosely

if true the types => T and ()T are seen as overriding each other.

relaxedCheck

if true type Null becomes a subtype of non-primitive value types in TypeComparer.

final def paramInfoss(using Context): List[List[Type]]

The parameter types of a PolyType or MethodType, Empty list for others

The parameter types of a PolyType or MethodType, Empty list for others

Attributes

final def paramNamess(using Context): List[List[TermName]]

The parameter names of a PolyType or MethodType, Empty list for others

The parameter names of a PolyType or MethodType, Empty list for others

Attributes

final def parentSymbols(include: Symbol => Boolean)(using Context): List[Symbol]

The least (wrt <:<) set of symbols satisfying the include predicate of which this type is a subtype

The least (wrt <:<) set of symbols satisfying the include predicate of which this type is a subtype

Attributes

def parents(using Context): List[Type]

The full parent types, including all type arguments

The full parent types, including all type arguments

Attributes

Returns the set of methods that are abstract and do not overlap with any of java.lang.Object methods.

Returns the set of methods that are abstract and do not overlap with any of java.lang.Object methods.

Conceptually, a SAM (functional interface) has exactly one abstract method. If an interface declares an abstract method overriding one of the public methods of java.lang.Object, that also does not count toward the interface's abstract method count.

Attributes

Returns:

the set of methods that are abstract and do not match any of java.lang.Object

See also:
def recoverable_&(that: Type)(using Context): Type

this & that, but handle CyclicReferences by falling back to safe_&.

this & that, but handle CyclicReferences by falling back to safe_&.

Attributes

def relaxed_<:<(that: Type)(using Context): Boolean

If this is a repeated type, its element type, otherwise the type itself

If this is a repeated type, its element type, otherwise the type itself

Attributes

def resultType(using Context): Type

The resultType of a LambdaType, or ExprType, the type itself for others

The resultType of a LambdaType, or ExprType, the type itself for others

Attributes

If this is an ignored proto type, its underlying type, otherwise the type itself

If this is an ignored proto type, its underlying type, otherwise the type itself

Attributes

def rewrapAnnots(tp: Type)(using Context): Type
final def safeAppliedTo(args: List[Type])(using Context): Type
Implicitly added by decorateTypeApplications

A cycle-safe version of appliedTo where computing type parameters do not force the typeconstructor. Instead, if the type constructor is completing, we make up hk type parameters matching the arguments. This is needed when unpickling Scala2 files such as scala.collection.generic.Mapfactory.

A cycle-safe version of appliedTo where computing type parameters do not force the typeconstructor. Instead, if the type constructor is completing, we make up hk type parameters matching the arguments. This is needed when unpickling Scala2 files such as scala.collection.generic.Mapfactory.

Attributes

Implicitly added by decorateTypeApplications

Dealias type if it can be done without forcing the TypeRef's info

Dealias type if it can be done without forcing the TypeRef's info

Attributes

def safe_&(that: Type)(using Context): Type

Safer version of &.

Safer version of &.

This version does not simplify the bounds of the intersection of two TypeBounds. The simplification done by & requires subtyping checks which may end up calling & again, in most cases this should be safe but because of F-bounded types, this can result in an infinite loop (which will be masked unless -Yno-deep-subtypes is enabled). pos/i536 demonstrates that the infinite loop can also involve lower bounds.

Attributes

def select(name: Name)(using Context): Type

The type <this . name> , reduced if possible

The type <this . name> , reduced if possible

Attributes

def select(name: Name, denot: Denotation)(using Context): Type

The type <this . name> with given denotation, reduced if possible.

The type <this . name> with given denotation, reduced if possible.

Attributes

def select(sym: Symbol)(using Context): Type

The type <this . sym>, reduced if possible

The type <this . sym>, reduced if possible

Attributes

def select(name: TermName)(using Context): TermRef
def select(name: TermName, sig: Signature, target: Name)(using Context): TermRef

Utility method to show the underlying type of a TypeProxy chain together with the proxy type itself.

Utility method to show the underlying type of a TypeProxy chain together with the proxy type itself.

Attributes

The signature of this type. This is by default NotAMethod, but is overridden for PolyTypes, MethodTypes, and TermRef types. (the reason why we deviate from the "final-method-with-pattern-match-in-base-class" pattern is that method signatures use caching, so encapsulation is improved using an OO scheme).

The signature of this type. This is by default NotAMethod, but is overridden for PolyTypes, MethodTypes, and TermRef types. (the reason why we deviate from the "final-method-with-pattern-match-in-base-class" pattern is that method signatures use caching, so encapsulation is improved using an OO scheme).

Attributes

def simplified(using Context): Type

A simplified version of this type which is equivalent wrt =:= to this type. This applies a typemap to the type which (as all typemaps) follows type variable instances and reduces typerefs over refined types. It also

A simplified version of this type which is equivalent wrt =:= to this type. This applies a typemap to the type which (as all typemaps) follows type variable instances and reduces typerefs over refined types. It also

  • re-evaluates all occurrences of And/OrType with &/| because what was a union or intersection of type variables might be a simpler type after the type variables are instantiated.
  • maps poly params in the current constraint set back to their type vars.
  • forces match types to be fully defined and tries to normalize them.

NOTE: Simplifying an intersection type might change its erasure (for example, the Java erasure of Object & Serializable is Object, but its simplification is Serializable). This means that simplification should never be used in a MethodicType, because that could lead to a different signature. Since this isn't very useful anyway, this method handles this by never simplifying inside a MethodicType, except for replacing type parameters with associated type variables.

Attributes

Remove all AnnotatedTypes wrapping this type.

Remove all AnnotatedTypes wrapping this type.

Attributes

Strip LazyRef wrappers

Strip LazyRef wrappers

Attributes

def stripPoly(using Context): Type

Strip PolyType prefixes

Strip PolyType prefixes

Attributes

Map a TypeVar to either its instance if it is instantiated, or its origin, if not, until the result is no longer a TypeVar. Identity on all other types.

Map a TypeVar to either its instance if it is instantiated, or its origin, if not, until the result is no longer a TypeVar. Identity on all other types.

Attributes

def stripped(using Context): Type

Strip TypeVars and Annotation and CapturingType wrappers

Strip TypeVars and Annotation and CapturingType wrappers

Attributes

final def subst(from: List[Symbol], to: List[Type])(using Context): Type

Substitute all types that refer in their symbol attribute to one of the symbols in from by the corresponding types in to.

Substitute all types that refer in their symbol attribute to one of the symbols in from by the corresponding types in to.

Attributes

final def subst(from: BindingType, to: BindingType)(using Context): Type

Substitute all types of the form TypeParamRef(from, N) by TypeParamRef(to, N).

Substitute all types of the form TypeParamRef(from, N) by TypeParamRef(to, N).

Attributes

final def substApprox(from: List[Symbol], to: List[Type])(using Context): Type

Substitute all occurrences of symbols in from by corresponding types in to. Unlike for subst, the to types can be type bounds. A TypeBounds target will be replaced by range that gets absorbed in an approximating type map.

Substitute all occurrences of symbols in from by corresponding types in to. Unlike for subst, the to types can be type bounds. A TypeBounds target will be replaced by range that gets absorbed in an approximating type map.

Attributes

final def substParam(from: ParamRef, to: Type)(using Context): Type

Substitute a bound type by some other type

Substitute a bound type by some other type

Attributes

final def substParams(from: BindingType, to: List[Type])(using Context): Type

Substitute bound types by some other types

Substitute bound types by some other types

Attributes

final def substRecThis(binder: RecType, tp: Type)(using Context): Type

Substitute all occurrences of RecThis(binder) by tp

Substitute all occurrences of RecThis(binder) by tp

Attributes

final def substSym(from: List[Symbol], to: List[Symbol])(using Context): Type

Substitute all occurrences of symbols in from by references to corresponding symbols in to

Substitute all occurrences of symbols in from by references to corresponding symbols in to

Attributes

final def substThis(cls: ClassSymbol, tp: Type)(using Context): Type

Substitute all occurrences of This(cls) by tp

Substitute all occurrences of This(cls) by tp

Attributes

final def substThisUnlessStatic(cls: ClassSymbol, tp: Type)(using Context): Type

As substThis, but only is class is a static owner (i.e. a globally accessible object)

As substThis, but only is class is a static owner (i.e. a globally accessible object)

Attributes

final def termSymbol(using Context): Symbol

The term symbol associated with the type

The term symbol associated with the type

Attributes

final def toBounds(using Context): TypeBounds
Implicitly added by decorateTypeApplications

Turns non-bounds types to type bounds. A (possible lambda abstracted) match type is turned into a match alias. Every other type is turned into a type alias

Turns non-bounds types to type bounds. A (possible lambda abstracted) match type is turned into a match alias. Every other type is turned into a type alias

Attributes

def toFunctionType(isJava: Boolean, dropLast: Int, alwaysDependent: Boolean)(using Context): Type

Turn type into a function type.

Turn type into a function type.

Attributes

alwaysDependent

if true, always create a dependent function type.

dropLast

the number of trailing parameters that should be dropped when forming the function type.

def toText(printer: Printer): Text

Convert to text

Convert to text

Attributes

def topType(using Context): Type
Implicitly added by decorateTypeApplications

The top type with the same kind as self. This is largest type capturing the parameter shape of a type without looking at precise bounds.

The top type with the same kind as self. This is largest type capturing the parameter shape of a type without looking at precise bounds.

  • The top-type of simple-kinded types is Any
  • A kind like (* -> *) -> * is represented by the top type [X1 <: [X2] =>> Any] =>> Any

Attributes

def translateFromRepeated(toArray: Boolean, translateWildcard: Boolean)(using Context): Type
Implicitly added by decorateTypeApplications

If this is a repeated parameter *T, translate it to either Seq[T] or Array[? <: T] depending on the value of toArray. Additionally, if translateWildcard is true, a wildcard type will be translated to *<?>. Other types are kept as-is.

If this is a repeated parameter *T, translate it to either Seq[T] or Array[? <: T] depending on the value of toArray. Additionally, if translateWildcard is true, a wildcard type will be translated to *<?>. Other types are kept as-is.

Attributes

Implicitly added by decorateTypeApplications

Translate T to T & Object in the situations where an Array[T] coming from Java would need to be interpreted as an Array[T & Object] to be erased correctly.

Translate T to T & Object in the situations where an Array[T] coming from Java would need to be interpreted as an Array[T & Object] to be erased correctly.

Object is the top-level type in Java, but when it appears in a Java signature we replace it by a special FromJavaObject type for convenience, this in turns requires us to special-case generic arrays as described in case 3 in the documentation of FromJavaObjectSymbol. This is necessary because a fully generic Java array erases to an array of Object, whereas a fully generic Scala array erases to Object to allow primitive arrays as subtypes.

Note: According to http://cr.openjdk.java.net/~briangoetz/valhalla/sov/02-object-model.html, it's possible that future JVMs will consider that:

int[] <: Integer[] <: Object[]

So hopefully our grand-children will not have to deal with this non-sense!

Attributes

def translateParameterized(from: ClassSymbol, to: ClassSymbol, wildcardArg: Boolean)(using Context): Type
Implicitly added by decorateTypeApplications

Translate a type of the form From[T] to either To[T] or To[? <: T] (if wildcardArg is set). Keep other types as they are. from and to must be static classes, both with one type parameter, and the same variance. Do the same for by name types => From[T] and => To[T]

Translate a type of the form From[T] to either To[T] or To[? <: T] (if wildcardArg is set). Keep other types as they are. from and to must be static classes, both with one type parameter, and the same variance. Do the same for by name types => From[T] and => To[T]

Attributes

Implicitly added by decorateTypeApplications

Translate a From[T] into a *T.

Translate a From[T] into a *T.

Attributes

If this type can be normalized at the top-level by rewriting match types of S[n] types, the result after applying all toplevel normalizations, otherwise NoType

If this type can be normalized at the top-level by rewriting match types of S[n] types, the result after applying all toplevel normalizations, otherwise NoType

Attributes

The set of type alias members of this type

The set of type alias members of this type

Attributes

final def typeConstructor(using Context): Type

The type constructor of an applied type, otherwise the type itself

The type constructor of an applied type, otherwise the type itself

Attributes

The set of type members of this type

The set of type members of this type

Attributes

The type parameter with given name. This tries first decls in order not to provoke a cycle by forcing the info. If that yields no symbol it tries member as an alternative.

The type parameter with given name. This tries first decls in order not to provoke a cycle by forcing the info. If that yields no symbol it tries member as an alternative.

Attributes

Implicitly added by decorateTypeApplications

If self is a generic class, its type parameter symbols, otherwise Nil

If self is a generic class, its type parameter symbols, otherwise Nil

Attributes

Implicitly added by decorateTypeApplications

The type parameters of this type are: For a ClassInfo type, the type parameters of its class. For a typeref referring to a class, the type parameters of the class. For a refinement type, the type parameters of its parent, dropping any type parameter that is-rebound by the refinement.

The type parameters of this type are: For a ClassInfo type, the type parameters of its class. For a typeref referring to a class, the type parameters of the class. For a refinement type, the type parameters of its parent, dropping any type parameter that is-rebound by the refinement.

Attributes

def typeSize(using Context): Int

The number of applications and refinements in this type, after all aliases are expanded

The number of applications and refinements in this type, after all aliases are expanded

Attributes

final def typeSymbol(using Context): Symbol

The type symbol associated with the type

The type symbol associated with the type

Attributes

def underlyingClassRef(refinementOK: Boolean)(using Context): Type

If this is a (possibly aliased, annotated, and/or parameterized) reference to a class, the class type ref, otherwise NoType.

If this is a (possibly aliased, annotated, and/or parameterized) reference to a class, the class type ref, otherwise NoType.

Attributes

refinementOK

If true we also skip refinements.

Useful for diagnostics: The underlying type if this type is a type proxy, otherwise NoType

Useful for diagnostics: The underlying type if this type is a type proxy, otherwise NoType

Attributes

The iterator of underlying types as long as type is a TypeProxy. Useful for diagnostics

The iterator of underlying types as long as type is a TypeProxy. Useful for diagnostics

Attributes

Is this type unusable for implicit search or overloading resolution since it has embedded errors that can match anything? This is weaker and more ad-hoc than isErroneous. The main differences are that we always consider aliases (since these are relevant for inference or resolution) but never consider prefixes (since these often do not constrain the search space anyway).

Is this type unusable for implicit search or overloading resolution since it has embedded errors that can match anything? This is weaker and more ad-hoc than isErroneous. The main differences are that we always consider aliases (since these are relevant for inference or resolution) but never consider prefixes (since these often do not constrain the search space anyway).

Attributes

final def widen(using Context): Type

Widen from singleton type to its underlying non-singleton base type by applying one or more underlying dereferences, Also go from => T to T. Identity for all other types. Example:

Widen from singleton type to its underlying non-singleton base type by applying one or more underlying dereferences, Also go from => T to T. Identity for all other types. Example:

class Outer { class C ; val x: C } def o: Outer <o.x.type>.widen = o.C

Attributes

final def widenDealias(using Context): Type

Perform successive widenings and dealiasings until none can be applied anymore

Perform successive widenings and dealiasings until none can be applied anymore

Attributes

Perform successive widenings and dealiasings while rewrapping annotations, until none can be applied anymore

Perform successive widenings and dealiasings while rewrapping annotations, until none can be applied anymore

Attributes

Perform successive widenings and dealiasings while rewrapping refining annotations, until none can be applied anymore

Perform successive widenings and dealiasings while rewrapping refining annotations, until none can be applied anymore

Attributes

final def widenExpr: Type

Widen from ExprType type to its result type. (Note: no stripTypeVar needed because TypeVar's can't refer to ExprTypes.)

Widen from ExprType type to its result type. (Note: no stripTypeVar needed because TypeVar's can't refer to ExprTypes.)

Attributes

final def widenIfUnstable(using Context): Type

Widen type if it is unstable (i.e. an ExprType, or TermRef to unstable symbol

Widen type if it is unstable (i.e. an ExprType, or TermRef to unstable symbol

Attributes

If this is a nullary method type, its result type

If this is a nullary method type, its result type

Attributes

final def widenSingleton(using Context): Type

Widen from singleton type to its underlying non-singleton base type by applying one or more underlying dereferences.

Widen from singleton type to its underlying non-singleton base type by applying one or more underlying dereferences.

Attributes

Widen all top-level singletons reachable by dealiasing and going to the operands of & and |. Overridden and cached in OrType.

Widen all top-level singletons reachable by dealiasing and going to the operands of & and |. Overridden and cached in OrType.

Attributes

final def widenSkolem(using Context): Type

If this is a skolem, its underlying type, otherwise the type itself

If this is a skolem, its underlying type, otherwise the type itself

Attributes

final def widenTermRefExpr(using Context): Type

Widen from TermRef to its underlying non-termref base type, while also skipping Expr types.

Widen from TermRef to its underlying non-termref base type, while also skipping Expr types.

Attributes

def widenUnion(using Context): Type

Widen this type and if the result contains embedded soft union types, replace them by their joins. "Embedded" means: inside type lambdas, intersections or recursive types, in prefixes of refined types, or in hard union types. If an embedded soft union is found, we first try to simplify or eliminate it by re-lubbing it while allowing type parameters to be constrained further. Any remaining union types are replaced by their joins.

Widen this type and if the result contains embedded soft union types, replace them by their joins. "Embedded" means: inside type lambdas, intersections or recursive types, in prefixes of refined types, or in hard union types. If an embedded soft union is found, we first try to simplify or eliminate it by re-lubbing it while allowing type parameters to be constrained further. Any remaining union types are replaced by their joins.

For instance, if A is an unconstrained type variable, then

  ArrayBuffer[Int] | ArrayBuffer[A]

is approximated by constraining A to be =:= to Int and returning ArrayBuffer[Int] instead of ArrayBuffer[? >: Int | A <: Int & A]

Exception (if -YexplicitNulls is set): if this type is a nullable union (i.e. of the form T | Null), then the top-level union isn't widened. This is needed so that type inference can infer nullable types.

Attributes

Overridden in OrType

Overridden in OrType

Attributes

def |(that: Type)(using Context): Type

Inherited methods

def fallbackToText(printer: Printer): Text

A fallback text representation, if the pattern matching in Printers does not have a case for this showable element

A fallback text representation, if the pattern matching in Printers does not have a case for this showable element

Attributes

Inherited from:
Showable

Attributes

Inherited from:
Hashable
def show(using Context): String

The string representation of this showable element.

The string representation of this showable element.

Attributes

Inherited from:
Showable
def showIndented(margin: Int)(using Context): String

The string representation with each line after the first one indented by the given given margin (in spaces).

The string representation with each line after the first one indented by the given given margin (in spaces).

Attributes

Inherited from:
Showable
def showSummary(depth: Int)(using Context): String

The summarized string representation of this showable element. Recursion depth is limited to some smallish value. Default is Config.summarizeDepth.

The summarized string representation of this showable element. Recursion depth is limited to some smallish value. Default is Config.summarizeDepth.

Attributes

Inherited from:
Showable
final def typeHash(bs: Binders, tp: Type): Int

Attributes

Inherited from:
Hashable

Concrete fields

val self: Type
Implicitly added by decorateTypeApplications