Quotes
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: Expr[T] =
  ${ /* (quotes: Quotes) ?=> */ myExpr }
def myExpr(using Quotes): Expr[T] =
  '{ f(${ /* (quotes: Quotes) ?=> */ myOtherExpr }) }
}
def myOtherExpr(using Quotes): Expr[U] = '{ ... }
Attributes
- Source
- Quotes.scala
- Graph
- 
    
- Supertypes
- Self type
Members list
Type members
Classlikes
Low-level Typed AST metaprogramming API.
Low-level Typed AST metaprogramming API.
Provides all functionality related to AST-based metaprogramming.
Each type XYZ in the API is defined as an abstract type type XYZ. Methods on XYZ are provided by a given XYZMethods which implements extension methods on XYZ in the trait XYZMethods. The XYZ module is defined by a val XYZ: XYZModule which contains the methods defined in XYZModule. Type tests (TypeTest) are also given to perform subtype checks on these types.
Type hierarchy
+- Tree -+- PackageClause
         |
         +- Statement -+- Import
         |             +- Export
         |             +- Definition --+- ClassDef
         |             |               +- TypeDef
         |             |               +- ValOrDefDef -+- DefDef
         |             |                               +- ValDef
         |             |
         |             +- Term --------+- Ref -+- Ident -+- Wildcard
         |                             |       +- Select
         |                             |
         |                             +- Literal
         |                             +- This
         |                             +- New
         |                             +- NamedArg
         |                             +- Apply
         |                             +- TypeApply
         |                             +- Super
         |                             +- Assign
         |                             +- Block
         |                             +- Closure
         |                             +- If
         |                             +- Match
         |                             +- SummonFrom
         |                             +- Try
         |                             +- Return
         |                             +- Repeated
         |                             +- Inlined
         |                             +- SelectOuter
         |                             +- While
         |                             +---+- Typed
         |                                /
         +- TypedOrTest +----------------·
         +- Bind
         +- Unapply
         +- Alternatives
         |
         +- CaseDef
         +- TypeCaseDef
         |
         +- TypeTree ----+- Inferred
         |               +- TypeIdent
         |               +- TypeSelect
         |               +- TypeProjection
         |               +- Singleton
         |               +- Refined
         |               +- Applied
         |               +- Annotated
         |               +- MatchTypeTree
         |               +- ByName
         |               +- LambdaTypeTree
         |               +- TypeBind
         |               +- TypeBlock
         |
         +- TypeBoundsTree
         +- WildcardTypeTree
+- ParamClause -+- TypeParamClause
                +- TermParamClause
+- TypeRepr -+- NamedType -+- TermRef
             |             +- TypeRef
             +- ConstantType
             +- SuperType
             +- Refinement
             +- AppliedType
             +- AnnotatedType
             +- AndOrType -+- AndType
             |             +- OrType
             +- MatchType
             +- ByNameType
             +- ParamRef
             +- ThisType
             +- RecursiveThis
             +- RecursiveType
             +- LambdaType -+- MethodOrPoly -+- MethodType
             |              |                +- PolyType
             |              +- TypeLambda
             +- MatchCase
             +- TypeBounds
             +- NoPrefix
             +- FlexibleType
+- MethodTypeKind -+- Contextual
                   +- Implicit
                   +- Plain
+- Selector -+- SimpleSelector
             +- RenameSelector
             +- OmitSelector
             +- GivenSelector
+- Signature
+- Position
+- SourceFile
+- Constant -+- BooleanConstant
             +- ByteConstant
             +- ShortConstant
             +- IntConstant
             +- LongConstant
             +- FloatConstant
             +- DoubleConstant
             +- CharConstant
             +- StringConstant
             +- UnitConstant
             +- NullConstant
             +- ClassOfConstant
+- Symbol
+- Flags
Attributes
- Source
- Quotes.scala
- Supertypes
- Self type
- 
               
Types
Type of a Quotes provided by a splice within a quote that took this context.
Type of a Quotes provided by a splice within a quote that took this context.
Attributes
- Source
- Quotes.scala
Value members
Abstract fields
Low-level Typed AST metaprogramming API.
Low-level Typed AST metaprogramming API.
Provides all functionality related to AST-based metaprogramming.
Usage:
import scala.quoted.*
def f(expr: Expr[Int])(using Quotes) =
  import quotes.reflect.*
  val ast: Term = expr.asTerm
  ???
See reflectModule for full API.
Attributes
- Source
- Quotes.scala
Extensions
Extensions
Convert this to an quoted.Expr[X] if this expression is a valid expression of type X or throws
Convert this to an quoted.Expr[X] if this expression is a valid expression of type X or throws
Attributes
- Source
- Quotes.scala
Deprecated extensions
Pattern matches this against that. Effectively performing a deep equality check. It does the equivalent of
Pattern matches this against that. Effectively performing a deep equality check. It does the equivalent of
this match
  case '{...} => true // where the contents of the pattern are the contents of `that`
  case _ => false
Attributes
- Source
- Quotes.scala
Show a source code like representation of this expression
Return the value of this expression.
Return the value of this expression.
Returns None if the expression does not represent a value or possibly contains side effects. Otherwise returns the Some of the value.
Attributes
- Source
- Quotes.scala
Return the value of this expression.
Return the value of this expression.
Emits an error and aborts if the expression does not represent a value or possibly contains side effects. Otherwise returns the value.
Attributes
- Source
- Quotes.scala
Return the value of this expression.
Return the value of this expression.
Emits an error and throws if the expression does not represent a value or possibly contains side effects. Otherwise returns the value.
Attributes
- Deprecated
- 
                [Since version 3.1.0]Use valueOrAbort
- Source
- Quotes.scala