summaryrefslogtreecommitdiff
path: root/test/files/run/macro-toplevel-companion-a/Impls_Macros_1.scala
blob: 23e8694ddc98b28d31644eb59042cd438f058106 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import scala.reflect.macros.Context
import language.experimental.macros

object Macros {
  def impl(c: Context) = {
    import c.universe._
    val synthetic = reify{ class C { override def toString = "C" }; object C { implicit val c = new C } }.tree
    val defs = synthetic.asInstanceOf[Block].stats.asInstanceOf[List[ImplDef]]
    if (c.topLevelRef(TypeName("C")).isEmpty) c.introduceTopLevel(nme.EMPTY_PACKAGE_NAME.toString, defs: _*)
    c.literalUnit
  }

  def foo = macro impl
}