Dotty Documentation

0.14.0-bin-SNAPSHOT

abstract class Type
extends Object with 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 ---+- ImplicitMethodType
                                                          +- ContextualMethodType
                     |                                    +- JavaMethodType
                     +- ClassInfo
                     |
                     +- NoType
                     +- NoPrefix
                     +- ErrorType
                     +- WildcardType

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

[-] Constructors

Type ( )
Type ( self: Type )
Type ( self: Type )

[-] Members

[+] @sharable private var mightBeProvisional : Boolean

A cache indicating whether the type was still provisional, last time we checked

[+] def & ( that: Type ) ( implicit ctx: Context ) : Type
[+] final def <:< ( that: Type ) ( implicit ctx: Context ) : Boolean

Is this type a subtype of that type?

[+] final def =:= ( that: Type ) ( implicit ctx: Context ) : Boolean

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

[+] def EtaExpand ( tparams: List [ TypeSymbol ] ) ( implicit ctx: Context ) : Type

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

[+] def EtaExpandIfHK ( bound: Type ) ( implicit ctx: Context ) : Type

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

[+] final def abstractTermMembers ( implicit ctx: Context ) : Seq [ SingleDenotation ]

The set of abstract term members of this type.

[+] final def abstractTypeMembers ( implicit ctx: Context ) : Seq [ SingleDenotation ]

The set of abstract type members of this type.

[+] def adaptHkVariances ( bound: Type ) ( implicit ctx: Context ) : Type

If argument A and type parameter P are higher-kinded, adapt the variances of A to those of P, ensuring that the variances of the type lambda A agree with the variances of corresponding higher-kinded type parameters of P. Example:

class GenericCompanion[+CC[X]] GenericCompanion[List]

with adaptHkVariances, the argument List will expand to

[X] => List[X]

instead of

[+X] => List[X]

even though List is covariant. This adaptation is necessary to ignore conflicting variances in overriding members that have types of hk-type parameters such as GenericCompanion[GenTraversable] or GenericCompanion[ListBuffer]. When checking overriding, we need to validate the subtype relationship

GenericCompanion[[X] -> ListBuffer[X]] <: GenericCompanion[[+X] -> GenTraversable[X]]

Without adaptation, this would be false, and hence an overriding error would result. But with adaptation, the rhs argument will be adapted to

[X] -> GenTraversable[X]

which makes the subtype test succeed. The crucial point here is that, since GenericCompanion only expects a non-variant CC, the fact that GenTraversable is covariant is irrelevant, so can be ignored.

[+] final def allMembers ( implicit ctx: Context ) : Seq [ SingleDenotation ]

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

[+] def annotatedToRepeated ( implicit ctx: Context ) : Type
[+] def appliedTo ( arg1: Type , arg2: Type ) ( implicit ctx: Context ) : Type
[+] def appliedTo ( args: List [ Type ] ) ( implicit ctx: Context ) : Type

The type representing

T[U1, ..., Un]

where

[+] def appliedTo ( arg: Type ) ( implicit ctx: Context ) : Type
[+] def applyIfParameterized ( args: List [ Type ] ) ( implicit ctx: Context ) : Type
[+] def argInfo ( implicit ctx: Context ) : Type

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

[+] def argInfos ( implicit ctx: Context ) : List [ Type ]

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.

[+] def argTypes ( implicit ctx: Context ) : List [ Type ]

Argument types where existential types in arguments are disallowed

[+] def argTypesHi ( implicit ctx: Context ) : List [ Type ]

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

[+] def argTypesLo ( implicit ctx: Context ) : List [ Type ]

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

[+] final def asSeenFrom ( pre: Type , cls: Symbol ) ( implicit ctx: Context ) : Type

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

[+] def baseClasses ( implicit ctx: Context ) : List [ ClassSymbol ]

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.

[+] final def baseType ( base: Symbol ) ( implicit ctx: Context ) : Type

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

[+] final def bounds ( implicit ctx: Context ) : TypeBounds

This type seen as a TypeBounds

[+] final def classSymbol ( implicit ctx: 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).

[+] final def classSymbols ( implicit ctx: Context ) : List [ ClassSymbol ]

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

[+] def computeHash ( bs: Binders ) : Int

Compute hashcode relative to enclosing binders bs

[+] def coveringSet ( implicit ctx: Context ) : Set [ Symbol ]

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

[+] final def dealias ( implicit ctx: 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.

[+] private def dealias1 ( keep: AnnotatedType => Context => Boolean ) ( implicit ctx: Context ) : Type
[+] final def dealiasKeepAnnots ( implicit ctx: 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.

[+] final def dealiasKeepRefiningAnnots ( implicit ctx: Context ) : Type

Like dealiasKeepAnnots, but keeps only refining annotations

[+] final def decl ( name: Name ) ( implicit ctx: 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.

[+] @tailrec final def decls ( implicit ctx: Context ) : Scope

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

[+] final def deconst ( implicit ctx: Context ) : Type

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

[+] def deepenProto ( implicit ctx: Context ) : Type

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

[+] def derivesAnnotWith ( p: Annotation => Boolean ) ( implicit ctx: Context ) : Boolean

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

[+] final def derivesFrom ( cls: Symbol ) ( implicit ctx: Context ) : Boolean

Is this type an instance of a non-bottom subclass of the given class cls?

[+] def dropAlias ( implicit ctx: Context ) : Type

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

[+] final def dropDependentRefinement ( implicit ctx: Context ) : Type

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

[+] def elemType ( implicit ctx: Context ) : Type

The element type of a sequence or array

[+] def ensureLambdaSub ( implicit ctx: Context ) : Type

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

[+] def ensureMethodic ( implicit ctx: Context ) : Type
[+] 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.

[+] 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.

[+] final def exists : Boolean

Is this type different from NoType?

[+] final def existsPart ( p: Type => Boolean , forceLazy: Boolean ) ( implicit ctx: Context ) : Boolean

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

[+] def existsPart$default$2 : Boolean

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

[+] final def fields ( implicit ctx: Context ) : Seq [ SingleDenotation ]
[+] def finalResultType ( implicit ctx: Context ) : Type

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

[+] @tailrec final def findDecl ( name: Name , excluded: FlagSet ) ( implicit ctx: 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.

[+] final def findMember ( name: Name , pre: Type , required: FlagConjunction , excluded: FlagSet ) ( implicit ctx: 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.

[+] final def firstParamTypes ( implicit ctx: Context ) : List [ Type ]

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

[+] def firstParent ( implicit ctx: Context ) : Type

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

[+] final def followSyntheticOpaque ( implicit ctx: Context ) : Type

If this is a synthetic opaque type seen from inside the opaque companion object, its opaque alias, otherwise the type itself.

[+] final def forallParts ( p: Type => Boolean ) ( implicit ctx: Context ) : Boolean

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

[+] final def foreachPart ( p: Type => Unit , stopAtStatic: Boolean ) ( implicit ctx: Context ) : Unit

Performs operation on all parts of this type

[+] def foreachPart$default$2 : Boolean

Performs operation on all parts of this type

[+] final def frozen_<:< ( that: Type ) ( implicit ctx: Context ) : Boolean

Is this type a subtype of that type?

[+] @tailrec final def hasAnnotation ( cls: ClassSymbol ) ( implicit ctx: Context ) : Boolean

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

[+] def hasAnyKind ( implicit ctx: Context ) : Boolean

Is this type of kind AnyKind?

[+] def hasSameKindAs ( other: Type ) ( implicit ctx: Context ) : Boolean

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.

[+] def hasSimpleKind ( implicit ctx: Context ) : Boolean

Is self type of kind "*"?

[+] 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.

[+] def hiBound : Type

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

[+] def hkResult ( implicit ctx: Context ) : Type

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

[+] def hkTypeParams ( implicit ctx: Context ) : List [ TypeParamInfo ]

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

[+] final def implicitMembers ( kind: FlagSet ) ( implicit ctx: Context ) : List [ TermRef ]

The set of implicit term members of this type

[+] def isArgPrefixOf ( symd: SymDenotation ) ( implicit ctx: Context ) : Boolean

True iff symd is a denotation of a class type parameter and the reference <this> . <symd> is an actual argument reference, i.e. this is different from the ThisType of symd's owner.

[+] def isBottomType ( implicit ctx: Context ) : Boolean

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

[+] def isContextual : Boolean

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

[+] def isDirectRef ( sym: Symbol ) ( implicit ctx: Context ) : Boolean

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

[+] def isErasedMethod : Boolean

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

[+] def isErasedValueType ( implicit ctx: Context ) : Boolean
[+] def isErroneous ( implicit ctx: Context ) : Boolean

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

[+] final def isError ( implicit ctx: Context ) : Boolean

Is this type produced as a repair for an error?

[+] final def isGround ( implicit ctx: Context ) : Boolean

Does this type not refer to TypeParamRefs or uninstantiated TypeVars?

[+] def isImplicit : Boolean

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

[+] def isImplicitMethod : Boolean

Is this a MethodType which has implicit or contextual parameters

[+] def isJavaMethod : Boolean

Is this a MethodType which is from Java

[+] def isLambdaSub ( implicit ctx: Context ) : Boolean

Is self type bounded by a type lambda or AnyKind?

[+] def isMatch ( implicit ctx: Context ) : Boolean

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

[+] final def isNotNull ( implicit ctx: Context ) : Boolean

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

[+] def isNullaryMethod ( implicit ctx: Context ) : Boolean

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

[+] final def isParameterless ( implicit ctx: Context ) : Boolean

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

[+] def isPrimitiveValueType ( implicit ctx: Context ) : Boolean
[+] def isProvisional ( implicit ctx: Context ) : Boolean

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.

[+] def isRef ( sym: Symbol ) ( implicit ctx: Context ) : Boolean

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

[+] def isRepeatedParam ( implicit ctx: Context ) : Boolean

Is this a type of a repeated parameter?

[+] def isSingleton ( implicit ctx: Context ) : Boolean

Is this type a (possibly aliased) singleton type?

[+] final def isStable ( implicit ctx: Context ) : Boolean

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.

[+] def isTightPrefix ( sym: Symbol ) ( implicit ctx: Context ) : Boolean

Does this type refer exactly to class symbol sym, instead of to a subclass of sym? Implemented like isRef, but follows more types: all type proxies as well as and- and or-types

[+] def isTopType ( implicit ctx: Context ) : Boolean

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

[+] final def isTypeAlias : Boolean

Is this an alias TypeBounds?

[+] def isValueSubType ( that: Type ) ( implicit ctx: Context ) : Boolean

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

[+] final def isValueType : Boolean

Is this type a value type?

[+] final def isValueTypeOrLambda : Boolean

Is this a value type or a type lambda?

[+] final def isValueTypeOrWildcard : Boolean

Is this a value type or a wildcard?

[+] def isVarArgsMethod ( implicit ctx: Context ) : Boolean

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

[+] 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).

[+] def loBound : Type

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

[+] def lookupRefined ( name: Name ) ( implicit ctx: 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

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.

[+] def mapReduceAnd ( f: Type => T ) ( g: (T, T) => T ) ( implicit ctx: Context ) : T

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

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

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

[+] def matches ( that: Type ) ( implicit ctx: Context ) : Boolean

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.

[+] def matchesLoosely ( that: Type ) ( implicit ctx: Context ) : Boolean

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

[+] final def member ( name: Name ) ( implicit ctx: Context ) : Denotation

The member of this type with the given name

[+] final def memberBasedOnFlags ( name: Name , required: FlagConjunction , excluded: FlagSet ) ( implicit ctx: Context ) : Denotation

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

[+] def memberBasedOnFlags$default$2 : FlagConjunction

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

[+] def memberBasedOnFlags$default$3 : FlagSet

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

[+] final def memberClasses ( implicit ctx: Context ) : Seq [ SingleDenotation ]

The set of member classes of this type

[+] def memberDenots ( keepOnly: NameFilter , f: (Name, Buffer [ SingleDenotation ]) => Unit ) ( implicit ctx: Context ) : Seq [ SingleDenotation ]
[+] final def memberInfo ( sym: Symbol ) ( implicit ctx: Context ) : Type

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

[+] final def memberNames ( keepOnly: NameFilter , pre: Type ) ( implicit ctx: 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.

[+] def memberNames$default$2 : Type

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.

[+] final def membersBasedOnFlags ( required: FlagConjunction , excluded: FlagSet ) ( implicit ctx: Context ) : Seq [ SingleDenotation ]

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

[+] @sharable private def mightBeProvisional_= ( x$1: Boolean ) : Unit

A cache indicating whether the type was still provisional, last time we checked

[+] final def namedParts ( implicit ctx: Context ) : Set [ NamedType ]

The parts of this type which are type or term refs

[+] def namedPartsWith ( p: NamedType => Boolean , excludeLowerBounds: Boolean ) ( implicit ctx: Context ) : Set [ NamedType ]

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

[+] def namedPartsWith$default$2 : Boolean

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

[+] def narrow ( implicit ctx: Context ) : TermRef

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

[+] final def nonClassTypeMembers ( implicit ctx: Context ) : Seq [ SingleDenotation ]

The set of abstract type members of this type.

[+] final def nonPrivateDecl ( name: Name ) ( implicit ctx: Context ) : Denotation

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

[+] final def nonPrivateMember ( name: Name ) ( implicit ctx: Context ) : Denotation

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

[+] final def normalized ( implicit ctx: Context ) : Type

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

[+] @tailrec final def normalizedPrefix ( implicit ctx: 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.

[+] def notApplied : Type

If this is a FunProto or PolyProto, WildcardType, otherwise this.

[+] def occursIn ( that: Type ) ( implicit ctx: Context ) : Boolean

Does this type occur as a part of type that?

[+] def orElse ( that: => Type ) : Type

This type, if it exists, otherwise that type

[+] final def overrides ( that: Type , matchLoosely: => Boolean ) ( implicit ctx: 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 if matchLoosely evaluates to true the types => T and ()T are seen as overriding each other.

[+] final def paramInfoss ( implicit ctx: Context ) : List [ List [ Type ] ]

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

[+] final def paramNamess ( implicit ctx: Context ) : List [ List [ TermName ] ]

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

[+] def parents ( implicit ctx: Context ) : List [ Type ]

The full parent types, including all type arguments

[+] def recoverable_& ( that: Type ) ( implicit ctx: Context ) : Type

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

[+] def relaxed_<:< ( that: Type ) ( implicit ctx: Context ) : Boolean
[+] def repeatedToSingle ( implicit ctx: Context ) : Type

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

[+] def resultType ( implicit ctx: Context ) : Type

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

[+] def revealIgnored : Type

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

[+] def rewrapAnnots ( tp: Type ) ( implicit ctx: Context ) : Type
[+] def safeAppliedTo ( args: List [ Type ] ) ( implicit ctx: Context ) : Type

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.

[+] def safeDealias ( implicit ctx: Context ) : Type

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

[+] def safe_& ( that: Type ) ( implicit ctx: Context ) : Type

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.

[+] def select ( name: Name ) ( implicit ctx: Context ) : Type

The type <this . name> , reduced if possible

[+] def select ( name: Name , denot: Denotation ) ( implicit ctx: Context ) : Type

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

[+] def select ( sym: Symbol ) ( implicit ctx: Context ) : Type

The type <this . sym>, reduced if possible

[+] def select ( name: TermName ) ( implicit ctx: Context ) : TermRef
[+] def select ( name: TermName , sig: Signature ) ( implicit ctx: Context ) : TermRef
[+] def showWithUnderlying ( n: Int ) ( implicit ctx: Context ) : String

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

[+] def showWithUnderlying$default$1 : Int

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

[+] def signature ( implicit ctx: Context ) : Signature

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).

[+] def simplified ( implicit ctx: 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 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. Finally, it maps poly params in the current constraint set back to their type vars.

[+] def stableHash : Boolean

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

[+] def stripAnnots ( implicit ctx: Context ) : Type

Remove all AnnotatedTypes wrapping this type.

[+] def stripPoly ( implicit ctx: Context ) : Type

Strip PolyType prefix

[+] def stripTypeVar ( implicit ctx: Context ) : Type

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.

[+] final def subst ( from: List [ Symbol ] , to: List [ Type ] ) ( implicit ctx: Context ) : Type

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

[+] final def subst ( from: BindingType , to: BindingType ) ( implicit ctx: Context ) : Type

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

[+] final def substParam ( from: ParamRef , to: Type ) ( implicit ctx: Context ) : Type

Substitute a bound type by some other type

[+] final def substParams ( from: BindingType , to: List [ Type ] ) ( implicit ctx: Context ) : Type

Substitute bound types by some other types

[+] final def substRecThis ( binder: RecType , tp: Type ) ( implicit ctx: Context ) : Type

Substitute all occurrences of RecThis(binder) by tp

[+] final def substSym ( from: List [ Symbol ] , to: List [ Symbol ] ) ( implicit ctx: Context ) : Type

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

[+] final def substThis ( cls: ClassSymbol , tp: Type ) ( implicit ctx: Context ) : Type

Substitute all occurrences of This(cls) by tp

[+] final def substThisUnlessStatic ( cls: ClassSymbol , tp: Type ) ( implicit ctx: Context ) : Type

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

[+] @tailrec final def termSymbol ( implicit ctx: Context ) : Symbol

The term symbol associated with the type

[+] private def testProvisional ( implicit ctx: Context ) : Boolean
[+] def toBounds ( implicit ctx: Context ) : TypeBounds

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

[+] def toFunctionType ( dropLast: Int ) ( implicit ctx: Context ) : Type

Turn type into a function type.

[+] def toFunctionType$default$1 : Int

Turn type into a function type.

[+] def toNestedPairs ( implicit ctx: Context ) : Type

The *: equivalent of an instantce of a Tuple class

[+] def toText ( printer: Printer ) : Text

Convert to text

[+] def translateParameterized ( from: ClassSymbol , to: ClassSymbol , wildcardArg: Boolean ) ( implicit ctx: Context ) : Type

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]

[+] def translateParameterized$default$3 : Boolean

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]

[+] def tryNormalize ( implicit ctx: Context ) : Type

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

[+] def tupleArity ( implicit ctx: Context ) : Int

The arity of this tuple type, which can be made up of Unit, TupleX and *: pairs, or -1 if this is not a tuple type.

[+] def tupleElementTypes ( implicit ctx: Context ) : List [ Type ]

The element types of this tuple type, which can be made up of Unit, TupleX and *: pairs

[+] final def typeAliasMembers ( implicit ctx: Context ) : Seq [ SingleDenotation ]

The set of type alias members of this type

[+] final def typeConstructor ( implicit ctx: Context ) : Type

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

[+] final def typeMembers ( implicit ctx: Context ) : Seq [ SingleDenotation ]

The set of type members of this type

[+] def typeParamNamed ( name: TypeName ) ( implicit ctx: Context ) : Symbol

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.

[+] def typeParamSymbols ( implicit ctx: Context ) : List [ TypeSymbol ]

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

[+] def typeParams ( implicit ctx: Context ) : List [ TypeParamInfo ]

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 typeref referring to a Lambda class, the type parameters of its right hand side or upper bound. For a refinement type, the type parameters of its parent, dropping any type parameter that is-rebound by the refinement.

[+] def typeSize ( implicit ctx: Context ) : Int

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

[+] @tailrec final def typeSymbol ( implicit ctx: Context ) : Symbol

The type symbol associated with the type

[+] def underlyingClassRef ( refinementOK: Boolean ) ( implicit ctx: Context ) : Type

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

[+] def underlyingIfProxy ( implicit ctx: Context ) : Type

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

[+] def underlyingIfRepeated ( isJava: Boolean ) ( implicit ctx: Context ) : Type

If this is repeated parameter type, its underlying Seq type, or, if isJava is true, Array type, else the type itself.

[+] def underlyingIterator ( implicit ctx: Context ) : Iterator [ Type ]

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

[+] final def widen ( implicit ctx: 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:

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

[+] final def widenDealias ( implicit ctx: Context ) : Type

Perform successive widenings and dealiasings until none can be applied anymore

[+] private def widenDealias1 ( keep: AnnotatedType => Context => Boolean ) ( implicit ctx: Context ) : Type
[+] final def widenDealiasKeepAnnots ( implicit ctx: Context ) : Type

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

[+] final def widenDealiasKeepRefiningAnnots ( implicit ctx: Context ) : Type

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

[+] final def widenExpr : Type

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

[+] final def widenIfUnstable ( implicit ctx: Context ) : Type

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

[+] final def widenSingleton ( implicit ctx: Context ) : Type

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

[+] final def widenSkolem ( implicit ctx: Context ) : Type

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

[+] final def widenTermRefExpr ( implicit ctx: Context ) : Type

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

[+] def widenUnion ( implicit ctx: Context ) : Type

If this type contains embedded union types, replace them by their joins. "Embedded" means: inside intersectons or recursive types, or in prefixes of refined types. If an embedded 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]

[+] def | ( that: Type ) ( implicit ctx: Context ) : Type