abstract class MacroExpander extends AnyRef
Performs macro expansion:
Expandable trees
A term of one of the following shapes:
Ident(<term macro>) Select(<any qualifier>, <term macro>) TypeApply(<any of the above>, <targs>) Apply(...Apply(<any of the above>, <args1>)...<argsN>)
Macro expansion
First of all macroExpandXXX
:
1) If necessary desugars the expandee
to fit into the default expansion scheme
that is understood by macroExpandWithRuntime
/ macroExpandWithoutRuntime
Then macroExpandWithRuntime
:
2) Checks whether the expansion needs to be delayed
3) Loads macro implementation using macroMirror
4) Synthesizes invocation arguments for the macro implementation
5) Checks that the result is a tree or an expr bound to this universe
Finally macroExpandXXX
:
6) Validates the expansion against the white list of supported tree shapes
7) Typechecks the result as required by the circumstances of the macro application
If -Ymacro-debug-lite is enabled, you will get basic notifications about macro expansion along with macro expansions logged in the form that can be copy/pasted verbatim into REPL.
If -Ymacro-debug-verbose is enabled, you will get detailed log of how exactly this function performs class loading and method resolution in order to load the macro implementation. The log will also include other non-trivial steps of macro expansion.
- returns
the expansion result if the expansion has been successful, the fallback tree if the expansion has been unsuccessful, but there is a fallback, the expandee unchanged if the expansion has been delayed, the expandee fully expanded if the expansion has been delayed before and has been expanded now, the expandee with an error marker set if the expansion has been cancelled due malformed arguments or implementation the expandee with an error marker set if there has been an error
- Source
- Macros.scala
- Alphabetic
- By Inheritance
- MacroExpander
- AnyRef
- Any
- by any2stringadd
- by StringFormat
- by Ensuring
- by ArrowAssoc
- Hide All
- Show All
- Public
- All
Instance Constructors
- new MacroExpander(typer: Analyzer.Typer, expandee: Global.Tree)
Abstract Value Members
- abstract def onFallback(expanded: Global.Tree): Global.Tree
- abstract def onSuccess(expanded: Global.Tree): Global.Tree
Concrete Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##(): Int
- Definition Classes
- AnyRef → Any
- def +(other: String): String
- Implicit
- This member is added by an implicit conversion from Analyzer.MacroExpander toany2stringadd[Analyzer.MacroExpander] performed by method any2stringadd in scala.Predef.
- Definition Classes
- any2stringadd
- def ->[B](y: B): (Analyzer.MacroExpander, B)
- Implicit
- This member is added by an implicit conversion from Analyzer.MacroExpander toArrowAssoc[Analyzer.MacroExpander] performed by method ArrowAssoc in scala.Predef.
- Definition Classes
- ArrowAssoc
- Annotations
- @inline()
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def apply(desugared: Global.Tree): Global.Tree
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- def ensuring(cond: (Analyzer.MacroExpander) => Boolean, msg: => Any): Analyzer.MacroExpander
- Implicit
- This member is added by an implicit conversion from Analyzer.MacroExpander toEnsuring[Analyzer.MacroExpander] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
- def ensuring(cond: (Analyzer.MacroExpander) => Boolean): Analyzer.MacroExpander
- Implicit
- This member is added by an implicit conversion from Analyzer.MacroExpander toEnsuring[Analyzer.MacroExpander] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
- def ensuring(cond: Boolean, msg: => Any): Analyzer.MacroExpander
- Implicit
- This member is added by an implicit conversion from Analyzer.MacroExpander toEnsuring[Analyzer.MacroExpander] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
- def ensuring(cond: Boolean): Analyzer.MacroExpander
- Implicit
- This member is added by an implicit conversion from Analyzer.MacroExpander toEnsuring[Analyzer.MacroExpander] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def expand(desugared: Global.Tree): Global.Tree
- Attributes
- protected
- val expandee: Global.Tree
- def finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- def formatted(fmtstr: String): String
- Implicit
- This member is added by an implicit conversion from Analyzer.MacroExpander toStringFormat[Analyzer.MacroExpander] performed by method StringFormat in scala.Predef.
- Definition Classes
- StringFormat
- Annotations
- @inline()
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- def onDelayed(expanded: Global.Tree): Global.Tree
- def onFailure(expanded: Global.Tree): Global.Tree
- def onSkipped(expanded: Global.Tree): Global.Tree
- def onSuppressed(expandee: Global.Tree): Global.Tree
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- val typer: Analyzer.Typer
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
Deprecated Value Members
- def →[B](y: B): (Analyzer.MacroExpander, B)
- Implicit
- This member is added by an implicit conversion from Analyzer.MacroExpander toArrowAssoc[Analyzer.MacroExpander] performed by method ArrowAssoc in scala.Predef.
- Definition Classes
- ArrowAssoc
- Annotations
- @deprecated
- Deprecated
(Since version 2.13.0) Use
->
instead. If you still wish to display it as one character, consider using a font with programming ligatures such as Fira Code.
The Scala compiler and reflection APIs.