blob: 9ed7c8788564995e3aae2e61262e83ad91c60e7d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
import scala.reflect.runtime.universe._
import scala.reflect.runtime.{currentMirror => cm}
import scala.tools.reflect.{ToolBox, ToolBoxError}
import definitions._
import Flag._
object Test extends App {
val tb = cm.mkToolBox()
val msg = internal.reificationSupport.newFreeTerm("msg", "C")
internal.reificationSupport.setTypeSignature(msg, typeOf[String])
try {
val csym = tb.define(q"""class C { override def toString = $msg }""")
println(tb.eval(q"new $csym"))
} catch {
case ToolBoxError(message, _) => println(s"compilation failed: $message")
}
}
|