aboutsummaryrefslogtreecommitdiff
path: root/tests/pending/run/macroPlugins-typedMacroBody/Plugin_1.scala
blob: e99cf7f75d711e0371f6394a85f841ff24ae3349 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package typedMacroBody

import scala.tools.nsc.Global
import scala.tools.nsc.plugins.{Plugin => NscPlugin}

class Plugin(val global: Global) extends NscPlugin {
  import global._
  import analyzer._

  val name = "typedMacroBody"
  val description = "A sample analyzer plugin that overrides typedMacroBody."
  val components = Nil
  addMacroPlugin(MacroPlugin)

  object MacroPlugin extends MacroPlugin {
    override def pluginsTypedMacroBody(typer: Typer, ddef: DefDef): Option[Tree] = {
      val DefDef(_, _, _, _, _, Literal(Constant(num: Int))) = ddef
      Some(standardTypedMacroBody(typer, copyDefDef(ddef)(rhs = Ident(TermName("impl" + num)))))
    }
  }
}