Type

scala.quoted.Type
See theType companion class
object Type

Methods to interact with the current Type[T] in scope.

Attributes

Companion
class
Source
Type.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Type.type

Members list

Value members

Concrete methods

def show[T <: AnyKind](using Type[T])(using Quotes): String

Shows a source code like representation of this type without syntax highlight.

Shows a source code like representation of this type without syntax highlight.

Type parameters

T

the type or type constructor to show

Attributes

Source
Type.scala
def valueOfConstant[T](using Type[T])(using Quotes): Option[T]

Extracts the value of a singleton constant type. Returns Some of the value of the type if it is a singleton constant type. Returns None if the type is not a singleton constant type.

Extracts the value of a singleton constant type. Returns Some of the value of the type if it is a singleton constant type. Returns None if the type is not a singleton constant type.

Example usage:

import scala.deriving.*
def f(using Quotes) = {
  import quotes.reflect.*
  val expr: Expr[Any] = ???
  expr match {
    case '{ $mirrorExpr : Mirror.Sum { type MirroredLabel = label } } =>
      Type.valueOfConstant[label] // Option[String]
  }
}

Type parameters

T

the singleton constant type to extract the value from

Attributes

Returns

Some with the constant value if T is a singleton constant type, None otherwise

Source
Type.scala
def valueOfTuple[T <: Tuple](using Type[T])(using Quotes): Option[T]

Extracts the value of a tuple of singleton constant types. Returns Some of the tuple type if it is a tuple singleton constant types. Returns None if the type is not a tuple singleton constant types.

Extracts the value of a tuple of singleton constant types. Returns Some of the tuple type if it is a tuple singleton constant types. Returns None if the type is not a tuple singleton constant types.

Example usage:

import scala.deriving.*
def f(using Quotes) = {
  import quotes.reflect.*
  val expr: Expr[Any] = ???
  expr match {
    case '{ type label <: Tuple; $mirrorExpr : Mirror.Sum { type MirroredElemLabels = `label` } } =>
      Type.valueOfTuple[label] // Option[Tuple]
  }
}

Type parameters

T

the tuple type of singleton constant types to extract values from

Attributes

Returns

Some with the tuple of constant values if all elements are singleton constant types, None otherwise

Source
Type.scala

Givens

Givens

given of: [T <: AnyKind] => Quotes => Type[T]

Returns a quoted.Type with the given type.

Returns a quoted.Type with the given type.

Attributes

Source
Type.scala