summaryrefslogtreecommitdiff
path: root/test/files/run/macro-reify-tagless-a/Test_2.scala
blob: afb418a7550e95774154d4a3213f538876c6aed2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
object Test extends App {
  //val list: List[String] = Macros.foo("hello world")
  //println(list)

  import scala.reflect.runtime.universe._
  import scala.reflect.runtime.{currentMirror => cm}
  import scala.tools.reflect.ToolBox
  val tpt = AppliedTypeTree(Ident(definitions.ListClass), List(Ident(definitions.StringClass)))
  val rhs = Apply(Select(Ident(TermName("Macros")), TermName("foo")), List(Literal(Constant("hello world"))))
  val list = ValDef(NoMods, TermName("list"), tpt, rhs)
  val tree = Block(List(list), Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Ident(list.name))))
  try cm.mkToolBox().eval(tree)
  catch { case ex: Throwable =>  println(ex.getMessage) }
}