summaryrefslogtreecommitdiff
path: root/test/pending/run/reify_maps.scala
blob: 589b28d049be7cbbb10240999644dfa1d7878ea9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import scala.tools.nsc.reporters._
import scala.tools.nsc.Settings
import reflect.runtime.Mirror.ToolBox

object Test extends App {
  val code = scala.reflect.Code.lift{
    val colors = Map("red" -> 0xFF0000,
                     "turquoise" -> 0x00FFFF,
                     "black" -> 0x000000,
                     "orange" -> 0xFF8040,
                     "brown" -> 0x804000)
    for (name <- List("red", "green", "blue", "turquoise")) println(
      colors.get(name) match {
        case Some(code) =>
          name + " has code: " + code
        case None =>
          "Unknown color: " + name
      }
    )
  };

  val reporter = new ConsoleReporter(new Settings)
  val toolbox = new ToolBox(reporter)
  val ttree = toolbox.typeCheck(code.tree)
  toolbox.runExpr(ttree)
}