Dotty Documentation

0.5.0-bin-SNAPSHOT

final class TypeApplications
extends AnyVal

A decorator that provides methods for modeling type application

[-] Constructors

TypeApplications ( self: Type )

[-] Members

[+] val self : Type
[+] 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

[+] 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 appliedTo ( args: List [ Type ] ) ( implicit ctx: Context ) : Type

The type representing

T[U1, ..., Un]

where

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

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

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

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

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

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

The element type of a sequence or array

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

If self is not higher-kinded, eta expand it.

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

Do self and other have the same kinds (not counting bounds and variances)

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

If self type is higher-kinded, its result type, otherwise NoType

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

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

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

Is self type higher-kinded (i.e. of kind != "*")?

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

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

Turns non-bounds types to type aliases

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

Translate a type of the form From[T] to To[T], 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]

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

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

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