scala.quoted
Members list
Packages
Type members
Classlikes
Quoted expression of type T.
Quoted expression of type T.
Expr has extension methods that are defined in scala.quoted.Quotes.
Type parameters
- T
-
the type of the quoted expression
Attributes
- Companion
- object
- Source
- Expr.scala
- Supertypes
Attributes
- Source
- ExprMap.scala
- Supertypes
Attributes
- Source
- Exprs.scala
- Supertypes
- Self type
-
Exprs.type
A type class for types that can convert a quoted.Expr[T] to a 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 XorX.applycan be lifted into its value - Arguments of constructors can be recursively unlifted
- This expression must be some kind of data structure (
Type parameters
- T
-
the type of the value that can be extracted from the quoted expression
Attributes
- Companion
- object
- Source
- FromExpr.scala
- Supertypes
- Known subtypes
Quotation context provided by a macro expansion or in the scope of scala.quoted.staging.run. Used to perform all operations on quoted Expr or Type.
Quotation context provided by a macro expansion or in the scope of scala.quoted.staging.run. Used to perform all operations on quoted Expr or Type.
It contains the low-level Typed AST API metaprogramming API. This API does not have the static type guarantees that Expr and Type provide. Quotes are generated from an enclosing ${ ... } or scala.staging.run. For example:
import scala.quoted.*
inline def myMacro[T]: T =
${ myMacroExpr[T] }
def myMacroExpr[T: Type](using Quotes): Expr[T] =
'{ f[T](${ myOtherExpr[Int] }) }
def myOtherExpr[U: Type](using Quotes): Expr[U] =
'{ ??? : U }
def f[T](x: Int): T = ???
Attributes
- Source
- Quotes.scala
- Supertypes
- Self type
A type class for types that can convert a value of T into quoted.Expr[T] an expression that will create a copy of the value.
A type class for types that can convert a value of T into quoted.Expr[T] an expression that will create a copy of the value.
Type parameters
- T
-
the type of the value to be lifted into an
Expr[T]
Attributes
- Companion
- object
- Source
- ToExpr.scala
- Supertypes
- Known subtypes
-
object ArrayOfBooleanToExprobject ArrayOfByteToExprobject ArrayOfCharToExprobject ArrayOfDoubleToExprobject ArrayOfFloatToExprobject ArrayOfIntToExprobject ArrayOfLongToExprobject ArrayOfShortToExprobject BigDecimalToExprobject BigIntToExprobject EmptyTupleToExprobject NilToExprobject NoneToExprobject StringContextToExprShow all
Type (or type constructor) T needed contextually when using T in a quoted expression '{... T ...}.
Type (or type constructor) T needed contextually when using T in a quoted expression '{... T ...}.
Type parameters
- T
-
the type or type constructor being represented
Attributes
- Companion
- object
- Source
- Type.scala
- Supertypes
Expression representation of literal sequence of expressions.
Expression representation of literal sequence of expressions.
Varargs can be used to create the an expression args that will be used as varargs '{ f($args: _*) } or it can be used to extract all the arguments of the a varargs.
Attributes
- Source
- Varargs.scala
- Supertypes
- Self type
-
Varargs.type
Value members
Concrete methods
Current Quotes in scope
Current Quotes in scope
Usage:
import scala.quoted.*
def myExpr[T](using Quotes): Expr[T] = {
import quotes.reflect.*
???
}
Value parameters
- q
-
the implicit
Quotesinstance in scope
Attributes
- Returns
-
the provided
Quotesinstance with its singleton type preserved - Source
- Quotes.scala