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 T1, ..., Tn in a context where type parameters U1,...,Un are expected to

LambdaXYZ { Apply = TCh...

Convert a type constructor TC which has type parameters T1, ..., Tn in a context where type parameters U1,...,Un are expected to

LambdaXYZ { Apply = TC[hk$0, ..., hk$n] }

Here, XYZ corresponds to the variances of - U1,...,Un if the variances of T1,...,Tn are pairwise compatible with U1,...,Un, - T1,...,Tn otherwise. v1 is compatible with v2, if v1 = v2 or v2 is non-variant.

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

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

[X] [List]

[X][X]

[+X][X]

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

[X][X]

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

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.

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

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

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

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

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

final def baseArgInfos ( base: Symbol ) ( implicit ctx: Context ) : List [ Type ]

The type arguments of this type's base type instance wrt. base. Existential types in arguments are returned as TypeBounds instances.

The type arguments of this type's base type instance wrt. base. Existential types in arguments are returned as TypeBounds instances.

final def baseArgTypes ( base: Symbol ) ( implicit ctx: Context ) : List [ Type ]

The type arguments of this type's base type instance wrt.base. Existential types in arguments are disallowed.

The type arguments of this type's base type instance wrt.base. Existential types in arguments are disallowed.

final def baseArgTypesHi ( base: Symbol ) ( implicit ctx: Context ) : List [ Type ]

The type arguments of this type's base type instance wrt.base. Existential types in arguments are approximated by their upper bound.

The type arguments of this type's base type instance wrt.base. Existential types in arguments are approximated by their upper bound.

final def baseArgTypesLo ( base: Symbol ) ( implicit ctx: Context ) : List [ Type ]

The type arguments of this type's base type instance wrt.base. Existential types in arguments are approximated by their lower bound.

The type arguments of this type's base type instance wrt.base. Existential types in arguments are approximated by their lower bound.

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

The base type including all type arguments and applicable refinements of this type. Refinements are applicable if they refine a member of the parent typ...

The base type including all type arguments and applicable refinements of this type. Refinements are applicable if they refine a member of the parent type which furthermore is not a name-mangled type parameter. Existential types in arguments are returned as TypeBounds instances.

def dropAlias ( implicit ctx: Context ) : Type

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

def elemType ( implicit ctx: Context ) : Type

The element type of a sequence or array

The element type of a sequence or array

def ensureHK ( implicit ctx: Context ) : Type

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

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

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

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

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 != "*")?

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

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

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

final def toBounds ( tparam: ParamInfo ) ( implicit ctx: Context ) : TypeBounds

Turn this type, which is used as an argument for type parameter tparam, into a TypeBounds RHS

Turn this type, which is used as an argument for type parameter tparam, into a TypeBounds RHS

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

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

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 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. "Re-bind" means: The refinement contains a TypeAlias for the type parameter, or it introduces bounds for the type parameter, and we are not in the special case of a type Lambda, where a LambdaTrait gets refined with the bounds on its hk args. See LambdaAbstract, where these types get introduced, and see isBoundedLambda below for the test.

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.

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

final def withoutArgs ( typeArgs: List [ Type ] ) : Type

The core type without any type arguments.

The core type without any type arguments.