FromExpr

scala.quoted.FromExpr
See theFromExpr companion object
trait FromExpr[T]

A type class for types that can convert a quoted.Expr[T] to a T.

  • Converts expression containing literal values to their values:
    • '{1} -> 1, '{2} -> 2, ...
    • For all primitive types and String
  • Converts an expression that constructs a copy of its value.
    • This expression must be some kind of data structure (Some, List, Either, ...)
    • Calls to new X or X.apply can be lifted into its value
    • Arguments of constructors can be recursively unlifted

Type parameters

T

the type of the value that can be extracted from the quoted expression

Attributes

Companion
object
Source
FromExpr.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes

Members list

Value members

Abstract methods

def unapply(x: Expr[T])(using Quotes): Option[T]

Returns the value of the expression.

Returns the value of the expression.

Returns None if the expression does not represent a value or possibly contains side effects. Otherwise returns the Some of the value.

Value parameters

x

the quoted expression to extract a value from

Attributes

Returns

Some(value) if the expression contains an extractable value, None otherwise

Source
FromExpr.scala