From 6e9ae187a05b1ca4fe748d8a7b45440a55ceb589 Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Mon, 5 Dec 2011 17:00:55 +0100 Subject: Another test pack for reflection Also see https://github.com/scala/scala/pull/25. --- test/pending/run/t5277_1.scala | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 test/pending/run/t5277_1.scala (limited to 'test/pending/run/t5277_1.scala') diff --git a/test/pending/run/t5277_1.scala b/test/pending/run/t5277_1.scala new file mode 100644 index 0000000000..57acd699ff --- /dev/null +++ b/test/pending/run/t5277_1.scala @@ -0,0 +1,21 @@ +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{ + def fact(n: Int): BigInt = + if (n == 0) 1 else fact(n-1) * n + class Factorizer(n: Int) { + def ! = fact(n) + } + implicit def int2fact(n: Int) = new Factorizer(n) + + println("10! = " + (10!)) + }; + + val reporter = new ConsoleReporter(new Settings) + val toolbox = new ToolBox(reporter) + val ttree = toolbox.typeCheck(code.tree) + toolbox.runExpr(ttree) +} -- cgit v1.2.3