Exprs

scala.quoted.Exprs
object Exprs

Attributes

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

Members list

Value members

Concrete methods

def unapply[T](exprs: Seq[Expr[T]])(using FromExpr[T])(using Quotes): Option[Seq[T]]

Matches literal sequence of literal constant value expressions and returns a sequence of values.

Matches literal sequence of literal constant value expressions and returns a sequence of values.

Usage:

inline def sum(args: Int*): Int = ${ sumExpr('args) }
def sumExpr(argsExpr: Expr[Seq[Int]])(using Quotes): Expr[Int] = argsExpr match
  case Varargs(Exprs(args)) => Expr(args.sum)
    // args: Seq[Int]

To directly get the value of all expressions in a sequence exprs: Seq[Expr[T]] consider using exprs.map(_.value)/exprs.map(_.valueOrError) instead.

Type parameters

T

the type of values being extracted from the expressions

Value parameters

exprs

the sequence of expressions to extract values from

Attributes

Returns

Some containing the sequence of extracted values if all expressions yield a value, or None if any expression cannot be converted

Source
Exprs.scala