summaryrefslogtreecommitdiff
path: root/test/files/pos
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2011-09-25 17:09:04 +0000
committerMartin Odersky <odersky@gmail.com>2011-09-25 17:09:04 +0000
commit274ce619902b1e92ec22fcff30b965fbbece2ad3 (patch)
treebec90e01d3dbbcd47dcabb487ba0cb43d7f1b81a /test/files/pos
parent5d5826812ae66b748342d86c5185e9bf7612fe7f (diff)
downloadscala-274ce619902b1e92ec22fcff30b965fbbece2ad3.tar.gz
scala-274ce619902b1e92ec22fcff30b965fbbece2ad3.tar.bz2
scala-274ce619902b1e92ec22fcff30b965fbbece2ad3.zip
Getting liftCode to work.
Diffstat (limited to 'test/files/pos')
-rw-r--r--test/files/pos/code.scala20
-rw-r--r--test/files/pos/t0651.scala4
-rw-r--r--test/files/pos/t531.scala10
-rw-r--r--test/files/pos/t532.scala10
4 files changed, 44 insertions, 0 deletions
diff --git a/test/files/pos/code.scala b/test/files/pos/code.scala
new file mode 100644
index 0000000000..4def5d2f94
--- /dev/null
+++ b/test/files/pos/code.scala
@@ -0,0 +1,20 @@
+import reflect.runtime.Mirror.ToolBox
+import scala.tools.nsc.reporters._
+import scala.tools.nsc.Settings
+
+object Test extends App {
+ def foo[T](ys: List[T]) = {
+ val fun: reflect.Code[Int => Int] = x => x + ys.length
+ fun
+ }
+ val code = foo(List(2))
+ val tree = code.tree.asInstanceOf[scala.reflect.runtime.Mirror.Tree]
+ val targetType = code.manifest.tpe.asInstanceOf[scala.reflect.runtime.Mirror.Type]
+ println("testing: "+tree)
+ val reporter = new ConsoleReporter(new Settings)
+ val toolbox = new ToolBox(reporter, args mkString " ")
+ val ttree = toolbox.typeCheck(tree, targetType)
+ println("result = "+ttree)
+}
+
+
diff --git a/test/files/pos/t0651.scala b/test/files/pos/t0651.scala
new file mode 100644
index 0000000000..52bef7e02b
--- /dev/null
+++ b/test/files/pos/t0651.scala
@@ -0,0 +1,4 @@
+object Reflection1 extends App {
+ case class Element(name: String)
+ println(reflect.Code.lift({val e = Element("someName"); e}).tree)
+}
diff --git a/test/files/pos/t531.scala b/test/files/pos/t531.scala
new file mode 100644
index 0000000000..02763e08f1
--- /dev/null
+++ b/test/files/pos/t531.scala
@@ -0,0 +1,10 @@
+object Test extends App {
+ import scala.reflect._;
+ def titi = {
+ var truc = 0
+ val tata: Code[()=>Unit] = () => {
+ truc = 6
+ }
+ ()
+ }
+}
diff --git a/test/files/pos/t532.scala b/test/files/pos/t532.scala
new file mode 100644
index 0000000000..32649b1629
--- /dev/null
+++ b/test/files/pos/t532.scala
@@ -0,0 +1,10 @@
+object Test extends App {
+ import scala.reflect._;
+ def titi: Unit = {
+ var truc = 0
+ val tata: Code[()=>Unit] = () => {
+ truc = truc + 6
+ }
+ ()
+ }
+}