TypeRepr

oxygen.quoted.TypeRepr
See theTypeRepr companion object
sealed trait TypeRepr extends Model

Attributes

Companion
object
Graph
Supertypes
trait Model
class Object
trait Matchable
class Any
Known subtypes
trait AndOrType
class AndType
class OrType
class AppliedType
class ByNameType
class ConstantType
class FlexibleType
trait LambdaType
trait MethodOrPoly
class MethodType
class PolyType
class TypeLambda
class MatchCase
class MatchType
trait NamedType
class TermRef
class TypeRef
class NoPrefix
class ParamRef
class Refinement
class SuperType
class ThisType
class TypeBounds
Show all

Members list

Type members

Types

type This <: TypeRepr

Value members

Concrete methods

final def <:<(that: TypeRepr): Boolean

Is this type a subtype of that type?

Is this type a subtype of that type?

Attributes

final def =:=(that: TypeRepr): Boolean

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

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

Attributes

final def andChildren: Set[TypeRepr]
final def appliedTo(targ: TypeRepr): TypeRepr

The current type applied to given type arguments: this[targ]

The current type applied to given type arguments: this[targ]

Attributes

final def appliedTo(targs: List[TypeRepr]): TypeRepr

The current type applied to given type arguments: this[targ0, ..., targN]

The current type applied to given type arguments: this[targ0, ..., targN]

Attributes

final def appliedTo(targ0: TypeRepr, targ1: TypeRepr, targN: TypeRepr*): TypeRepr
final def asType: Type[_ <: AnyKind]

Convert this TypeRepr to an Type[?]

Convert this TypeRepr to an Type[?]

Usage:

import scala.quoted.*
def f(using Quotes) = {
  val q: Quotes = summon[Quotes]
  import q.reflect.*
  val typeRepr: TypeRepr = ???
  typeRepr.asType match
    case '[t] =>
      '{ val x: t = ??? }
}

Attributes

final def asTypeOf[A]: Type[A]
final def baseClasses: List[Symbol]

The base classes of this type with the class itself as first element.

The base classes of this type with the class itself as first element.

Attributes

final def baseType(cls: Symbol): TypeRepr

The least type instance of given class which is a super-type of this type. Example:

The least type instance of given class which is a super-type of this type. Example:

  class D[T]
  class C extends p.D[Int]
  ThisType(C).baseType(D) = p.D[Int]

Attributes

final def classSymbol: Option[Symbol]
final def dealias: TypeRepr

Follow aliases, annotated types until type is no longer alias type, annotated type.

Follow aliases, annotated types until type is no longer alias type, annotated type.

Attributes

Follow non-opaque aliases, annotated types until type is no longer alias type, annotated type.

Follow non-opaque aliases, annotated types until type is no longer alias type, annotated type.

Attributes

final def derivesFrom(cls: Symbol): Boolean

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

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

Attributes

final def isContextFunctionType: Boolean

Is this type an context function type?

Is this type an context function type?

Attributes

See also

isFunctionType

final def isDependentFunctionType: Boolean

Is this type a dependent function type?

Is this type a dependent function type?

Attributes

See also

isFunctionType

final def isErasedFunctionType: Boolean

Is this type a function type with erased parameters?

Is this type a function type with erased parameters?

Attributes

See also

isFunctionType

final def isFunctionType: Boolean

Is this type a function type?

Is this type a function type?

Attributes

Returns

true if the dealiased type of self without refinement is FunctionN[T1, T2, ..., Tn]

Note

The function

  • returns true for given Int => Int and erased Int => Int
  • returns false for List[Int], despite that List[Int] <:< Int => Int.
final def isSingleton: Boolean
final def isTupleN: Boolean

Is this type a TupleN type?

Is this type a TupleN type?

Attributes

Returns

true if the dealiased type of self is TupleN[T1, T2, ..., Tn]

final override def maybePos: Option[Position]

Attributes

Definition Classes
final def memberType(member: Symbol): TypeRepr

The type of member as seen from prefix self.

The type of member as seen from prefix self.

Also see typeRef and termRef

Attributes

final def orChildren: Set[TypeRepr]
final def select(sym: Symbol): TypeRepr

The type <this . sym>, reduced if possible

The type <this . sym>, reduced if possible

Attributes

final def show(using printer: Printer[TypeRepr]): String

Shows the type as a String

Shows the type as a String

Attributes

final def show(f: PrinterCompanion => Printer[TypeRepr]): String
final def showAnsiCode: String
final def showCode: String
final def showShortCode: String
final def showStructure: String
final def showWith(f: PrinterCompanion => Printer[TypeRepr]): String
final def simplified: TypeRepr

A simplified version of this type which is equivalent wrt =:= to this type. Reduces typerefs, applied match types, and and or types.

A simplified version of this type which is equivalent wrt =:= to this type. Reduces typerefs, applied match types, and and or types.

Attributes

final def substituteTypes(from: List[Symbol], to: List[TypeRepr]): TypeRepr

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 termSymbol: Symbol
final def typeArgs: List[TypeRepr]

The applied type arguments (empty if there is no such arguments)

The applied type arguments (empty if there is no such arguments)

Attributes

final def typeSymbol: Symbol
final def typeTree: TypeTree
final def typeType: Option[TypeType]
final def typeTypeCase: Option[Case]
final def typeTypeCaseClass: Option[Class]
final def typeTypeCaseObject: Option[Object]
final def typeTypeSealed: Option[Sealed]
def unwrapWithin(using newQuotes: Quotes): newQuotes.reflect.TypeRepr
final def widen: TypeRepr

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 widenByName: TypeRepr

Widen from ByName type to its result type.

Widen from ByName type to its result type.

Attributes

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

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

Attributes

Inherited methods

final override def equals(that: Any): Boolean

Compares the receiver object (this) with the argument object (that) for equivalence.

Compares the receiver object (this) with the argument object (that) for equivalence.

Any implementation of this method should be an equivalence relation:

  • It is reflexive: for any instance x of type Any, x.equals(x) should return true.
  • It is symmetric: for any instances x and y of type Any, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any instances x, y, and z of type Any if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.

If you override this method, you should verify that your implementation remains an equivalence relation. Additionally, when overriding this method it is usually necessary to override hashCode to ensure that objects which are "equal" (o1.equals(o2) returns true) hash to the same scala.Int. (o1.hashCode.equals(o2.hashCode)).

Value parameters

that

the object to compare against this object for equality.

Attributes

Returns

true if the receiver object is equivalent to the argument; false otherwise.

Definition Classes
Model -> Any
Inherited from:
Model
final override def hashCode(): Int

Calculates a hash code value for the object.

Calculates a hash code value for the object.

The default hashing algorithm is platform dependent.

Note that it is allowed for two objects to have identical hash codes (o1.hashCode.equals(o2.hashCode)) yet not be equal (o1.equals(o2) returns false). A degenerate implementation could always return 0. However, it is required that if two objects are equal (o1.equals(o2) returns true) that they have identical hash codes (o1.hashCode.equals(o2.hashCode)). Therefore, when overriding this method, be sure to verify that the behavior is consistent with the equals method.

Attributes

Returns

the hash code value for this object.

Definition Classes
Model -> Any
Inherited from:
Model
final override def toString: String

Returns a string representation of the object.

Returns a string representation of the object.

The default representation is platform dependent.

Attributes

Returns

a string representation of the object.

Definition Classes
Model -> Any
Inherited from:
Model

Abstract fields

val quotes: Quotes
val unwrap: quotes.reflect.TypeRepr

Givens

Givens

given givenQuotes: quotes.type