summaryrefslogtreecommitdiff
path: root/test/pending
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2012-02-12 23:07:30 +0100
committerEugene Burmako <xeno.by@gmail.com>2012-02-12 23:07:33 +0100
commit6548dcf12d83e327df2f90048140fb95346b7e95 (patch)
treee20b3b6ce697af665983c3cc510d763a926650c6 /test/pending
parent6b56405cb39b979dccbadd06110e283a254b6150 (diff)
downloadscala-6548dcf12d83e327df2f90048140fb95346b7e95.tar.gz
scala-6548dcf12d83e327df2f90048140fb95346b7e95.tar.bz2
scala-6548dcf12d83e327df2f90048140fb95346b7e95.zip
reifyAnnotations
Annotations are now supported by the reifier: * AnnotationInfos from symbols get transformed back into mods. * AnnotatedTypes are retained and are reified along with AnnotationInfos. Reification is no magic, and reification of annotations especially: * Annotations cannot refer to symbols defined inside the quasiquote. This restriction is due to the fact that we need to erase locally defined symbols before reifying to make subsequent reflective compilations succeed. However, while doing that, we also need to make sure that we don't make resulting ASTs non-compilable by removing essential information. This is tricky, and it more or less works for TypeTrees, but not for annotations that can contain arbitrary ASTs. For more details look into the comments to Reifiers.scala. * Classfile annotations that contain array arguments and are applied to types, i.e. the ones that generate AnnotatedTypes, cannot be reified. This is because of limitations of manifest infrastructure. Typechecking "Array(mirror.LiteralAnnotArg(...))" would require the compiler to produce a manifest for a path-dependent type, which cannot be done now. Review by @odersky.
Diffstat (limited to 'test/pending')
-rw-r--r--test/pending/run/reify_classfileann_b.check0
-rw-r--r--test/pending/run/reify_classfileann_b.scala28
-rw-r--r--test/pending/run/t5224.check9
-rw-r--r--test/pending/run/t5224.scala8
-rw-r--r--test/pending/run/t5225_1.check4
-rw-r--r--test/pending/run/t5225_1.scala8
-rw-r--r--test/pending/run/t5225_2.check4
-rw-r--r--test/pending/run/t5225_2.scala8
8 files changed, 28 insertions, 41 deletions
diff --git a/test/pending/run/reify_classfileann_b.check b/test/pending/run/reify_classfileann_b.check
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/test/pending/run/reify_classfileann_b.check
diff --git a/test/pending/run/reify_classfileann_b.scala b/test/pending/run/reify_classfileann_b.scala
new file mode 100644
index 0000000000..b76dd8fc9f
--- /dev/null
+++ b/test/pending/run/reify_classfileann_b.scala
@@ -0,0 +1,28 @@
+import scala.reflect._
+import scala.reflect.api._
+import scala.tools.nsc.reporters._
+import scala.tools.nsc.Settings
+import reflect.runtime.Mirror.ToolBox
+
+class ann(bar: String, quux: Array[String] = Array(), baz: ann = null) extends ClassfileAnnotation
+
+object Test extends App {
+ // test 1: reify
+ val tree = scala.reflect.Code.lift{
+ class C {
+ def x: Int = {
+ 2: @ann(bar="1", quux=Array("2", "3"), baz = new ann(bar = "4"))
+ }
+ }
+ }.tree
+ println(tree.toString)
+
+ // test 2: import and typecheck
+ val reporter = new ConsoleReporter(new Settings)
+ val toolbox = new ToolBox(reporter)
+ val ttree = toolbox.typeCheck(tree)
+ println(ttree.toString)
+
+ // test 3: import and compile
+ toolbox.runExpr(ttree)
+} \ No newline at end of file
diff --git a/test/pending/run/t5224.check b/test/pending/run/t5224.check
deleted file mode 100644
index 2b920773c0..0000000000
--- a/test/pending/run/t5224.check
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- @serializable class C extends Object with ScalaObject {
- def <init>() = {
- super.<init>();
- ()
- }
- };
- ()
-} \ No newline at end of file
diff --git a/test/pending/run/t5224.scala b/test/pending/run/t5224.scala
deleted file mode 100644
index 865ce4bfe9..0000000000
--- a/test/pending/run/t5224.scala
+++ /dev/null
@@ -1,8 +0,0 @@
-import scala.reflect._
-import scala.reflect.api._
-
-object Test extends App {
- println(scala.reflect.Code.lift{
- @serializable class C
- }.tree.toString)
-} \ No newline at end of file
diff --git a/test/pending/run/t5225_1.check b/test/pending/run/t5225_1.check
deleted file mode 100644
index b29cd9c365..0000000000
--- a/test/pending/run/t5225_1.check
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- @transient @volatile var x: Int = 2;
- ()
-} \ No newline at end of file
diff --git a/test/pending/run/t5225_1.scala b/test/pending/run/t5225_1.scala
deleted file mode 100644
index 454502e810..0000000000
--- a/test/pending/run/t5225_1.scala
+++ /dev/null
@@ -1,8 +0,0 @@
-import scala.reflect._
-import scala.reflect.api._
-
-object Test extends App {
- println(scala.reflect.Code.lift{
- @transient @volatile var x = 2
- }.tree.toString)
-} \ No newline at end of file
diff --git a/test/pending/run/t5225_2.check b/test/pending/run/t5225_2.check
deleted file mode 100644
index 88972fd27f..0000000000
--- a/test/pending/run/t5225_2.check
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- def foo(@cloneable x: Int): String = "";
- ()
-}
diff --git a/test/pending/run/t5225_2.scala b/test/pending/run/t5225_2.scala
deleted file mode 100644
index 82bad0f353..0000000000
--- a/test/pending/run/t5225_2.scala
+++ /dev/null
@@ -1,8 +0,0 @@
-import scala.reflect._
-import scala.reflect.api._
-
-object Test extends App {
- println(scala.reflect.Code.lift{
- def foo(@cloneable x: Int) = ""
- }.tree.toString)
-} \ No newline at end of file