Type

object Type

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

Companion:
class
Source:
Type.scala
class Object
trait Matchable
class Any
Type.type

Value members

Concrete methods

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

Show a source code like representation of this type without syntax highlight

Show a source code like representation of this type without syntax highlight

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:

package scala.quoted
trait Snippet0 { self: quoted.Type.type =>
  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]
  }
  }
}
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:

package scala.quoted
trait Snippet0 { self: quoted.Type.type =>
  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]
  }
  }
}
Source:
Type.scala

Givens

Givens

@compileTimeOnly("Reference to `scala.quoted.Type.of` was not handled by PickleQuotes")
given of[T <: AnyKind](using Quotes): Type[T]

Return a quoted.Type with the given type

Return a quoted.Type with the given type

Source:
Type.scala