Packages

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
Linear Supertypes
AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. MacroExpander
  2. AnyRef
  3. Any
Implicitly
  1. by any2stringadd
  2. by StringFormat
  3. by Ensuring
  4. by ArrowAssoc
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new MacroExpander(typer: Analyzer.Typer, expandee: Global.Tree)

Abstract Value Members

  1. abstract def onFallback(expanded: Global.Tree): Global.Tree
  2. abstract def onSuccess(expanded: Global.Tree): Global.Tree

Concrete Value Members

  1. def apply(desugared: Global.Tree): Global.Tree
  2. val expandee: Global.Tree
  3. def onDelayed(expanded: Global.Tree): Global.Tree
  4. def onFailure(expanded: Global.Tree): Global.Tree
  5. def onSkipped(expanded: Global.Tree): Global.Tree
  6. def onSuppressed(expandee: Global.Tree): Global.Tree
  7. val typer: Analyzer.Typer