TypeReprMethods

Extension methods of TypeRepr

Source:
Quotes.scala
class Object
trait Matchable
class Any

Extensions

Extensions

extension (self: TypeRepr)
def <:<(that: TypeRepr): Boolean

Is this type a subtype of that type?

Is this type a subtype of that type?

Source:
Quotes.scala
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.

Source:
Quotes.scala

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

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

Source:
Quotes.scala

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

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

Source:
Quotes.scala
def asType: Type[_ <: AnyKind]

Convert this TypeRepr to an Type[?]

Convert this TypeRepr to an Type[?]

Usage:

package scala.quoted
trait Snippet0 { self: runtime.QuoteUnpickler & scala.quoted.runtime.QuoteMatching &    scala.quoted.Quotes =>
  val QuoteUnpickler = self
  val QuoteMatching = self
  val Quotes = self
  trait Snippet1 { self: Quotes.reflect.type /*Quotes.reflectModule*/ &    Quotes.reflectModule =>
    val reflect = self
    val reflectModule = self
    trait Snippet2 { self: reflectModule.TypeReprMethods =>
      val TypeReprMethods = self
      def f(using Quotes) = {
      val typeRepr: TypeRepr = ???
      typeRepr.asType match
        case '[t] =>
          '{ val x: t = ??? }
      }
    }
  }
}
Source:
Quotes.scala

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.

Source:
Quotes.scala

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

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]
Source:
Quotes.scala

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.

Source:
Quotes.scala

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?

Source:
Quotes.scala

Is this type an context function type?

Is this type an context function type?

See also:

isFunctionType

Source:
Quotes.scala

Is this type a dependent function type?

Is this type a dependent function type?

See also:

isFunctionType

Source:
Quotes.scala

Is this type an erased function type?

Is this type an erased function type?

See also:

isFunctionType

Source:
Quotes.scala

Is this type a function type?

Is this type a function type?

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.

Source:
Quotes.scala

Is this type a TupleN type?

Is this type a TupleN type?

Returns:

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

Source:
Quotes.scala

The type

The type sym>, reduced if possible

Source:
Quotes.scala

Shows the type as a String

Shows the type as a String

Source:
Quotes.scala

A simplified version of this type which is equivalent wrt =:= to this type.

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

Source:
Quotes.scala

Widen from singleton type to its underlying non-singleton base type by applying one or more underlying dereferences, Also go from => T to T.

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 .widen = o.C

Source:
Quotes.scala

Widen from ByName type to its result type.

Widen from ByName type to its result type.

Source:
Quotes.scala

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.

Source:
Quotes.scala