summaryrefslogtreecommitdiff
path: root/test/files/run/macro-bodyexpandstoimpl/Impls_1.scala
blob: d46af4952dcc8214c3d8e1e8ce82f29b3b02b6d3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import scala.language.experimental.macros
import scala.reflect.macros.blackbox.{Context => BlackboxContext}
import scala.reflect.macros.whitebox.{Context => WhiteboxContext}

object Impls {
  def foo(c: BlackboxContext)(x: c.Expr[Int]) = x

  def refToFoo(dummy: Int): Int = macro refToFoo_impl
  def refToFoo_impl(c: WhiteboxContext)(dummy: c.Expr[Int]) = {
    import c.universe._
    val body = Select(Ident(TermName("Impls")), TermName("foo"))
    val global = c.universe.asInstanceOf[scala.tools.nsc.Global]
    global.analyzer.markMacroImplRef(body.asInstanceOf[global.Tree])
    c.Expr[Int](body)
  }
}