ConstExpr

object ConstExpr
class Object
trait Matchable
class Any

Value members

Concrete methods

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

Matches expressions containing literal constant values and extracts the value.

Matches expressions containing literal constant values and extracts the value.

  • Converts expression containg literal values to their values:
    • '{1} -> 1, '{2} -> 2, ...
    • For all primitive types and String

Usage:

case '{ ... ${expr @ ConstExpr(value)}: T ...} =>
  // expr: Expr[T]
  // value: T

To directly unlift an expression expr: Expr[T] consider using expr.unlift/expr.unliftOrError insead.