1
import scala.reflect.runtime.universe._
2
import scala.reflect.runtime.{universe => ru}
3
import scala.reflect.runtime.{currentMirror => cm}
4
import scala.tools.reflect.ToolBox
6
object Test extends App {
8
def foo[T: TypeTag](ys: List[T]): Int => Int = {
11
val fun = reify{(x: Int) => {
16
x + ys.length * z + q + y
19
val toolbox = cm.mkToolBox()
20
val dyn = toolbox.eval(fun.tree)
21
dyn.asInstanceOf[Int => Int]
24
val fun1 = foo(List(1, 2, 3))
25
println("first invocation = " + fun1(10))
26
val fun2 = foo(List(1, 2, 3, 4))
27
println("second invocation = " + fun2(10))
28
println("q after second invocation = " + q)
b'\\ No newline at end of file'