diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2012-02-02 15:29:55 +0100 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2012-02-02 15:29:55 +0100 |
commit | 363f8af6a8c157485a644d00d75e2df10e71e661 (patch) | |
tree | 2cd691f5966c0c823f85abc94f8eef0057f676ff /test/files/run/reify_closure6.scala | |
parent | d940371bd50098c4146e52941880ccdbcb4ea47a (diff) | |
download | scala-363f8af6a8c157485a644d00d75e2df10e71e661.tar.gz scala-363f8af6a8c157485a644d00d75e2df10e71e661.tar.bz2 scala-363f8af6a8c157485a644d00d75e2df10e71e661.zip |
Fixes reifyThis
Diffstat (limited to 'test/files/run/reify_closure6.scala')
-rw-r--r-- | test/files/run/reify_closure6.scala | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/files/run/reify_closure6.scala b/test/files/run/reify_closure6.scala new file mode 100644 index 0000000000..54f1791bf2 --- /dev/null +++ b/test/files/run/reify_closure6.scala @@ -0,0 +1,28 @@ +import scala.tools.nsc.reporters._ +import scala.tools.nsc.Settings +import reflect.runtime.Mirror.ToolBox + +object Test extends App { + var q = 0 + def foo[T](ys: List[T]): Int => Int = { + val z = 1 + var y = 0 + val fun: reflect.Code[Int => Int] = x => { + y += 1 + q += 1 + println("q = " + q) + println("y = " + y) + x + ys.length * z + q + y + } + + val reporter = new ConsoleReporter(new Settings) + val toolbox = new ToolBox(reporter) + val ttree = toolbox.typeCheck(fun.tree) + val dyn = toolbox.runExpr(ttree) + dyn.asInstanceOf[Int => Int] + } + + println("first invocation = " + foo(List(1, 2, 3))(10)) + println("second invocation = " + foo(List(1, 2, 3, 4))(10)) + println("q after second invocation = " + q) +}
\ No newline at end of file |