summaryrefslogtreecommitdiff
path: root/test/files/run/macro-reify-type/Test_2.scala
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2012-09-23 14:07:22 +0200
committerEugene Burmako <xeno.by@gmail.com>2012-09-28 14:21:45 +0200
commita6b81ac12a45866e97d30133c12dee775b93ea39 (patch)
tree89020413a56a36ebde3a02b99e4ec367f81cf33c /test/files/run/macro-reify-type/Test_2.scala
parent4e87654a9187fc65e5971580f4e25589fff052b9 (diff)
downloadscala-a6b81ac12a45866e97d30133c12dee775b93ea39.tar.gz
scala-a6b81ac12a45866e97d30133c12dee775b93ea39.tar.bz2
scala-a6b81ac12a45866e97d30133c12dee775b93ea39.zip
SI-6417 correctly reifies non-value types
If we're reifying non-value types (e.g. MethodTypes), we can't use them as type arguments for TypeTag/WeakTypeTag factory methods, otherwise the macro expansion won't typecheck: http://groups.google.com/group/scala-internals/browse_thread/thread/2d7bb85bfcdb2e2 This situation is impossible if one uses only reify and type tags, but c.reifyTree and c.reifyType exposes in the macro API let anyone feed anything into the reifier. Therefore I now check the tpe that is about to be used in TypeApply wrapping TypeTag/WeakTypeTag factory methods and replace it with AnyTpe if it doesn't fit.
Diffstat (limited to 'test/files/run/macro-reify-type/Test_2.scala')
-rw-r--r--test/files/run/macro-reify-type/Test_2.scala21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/files/run/macro-reify-type/Test_2.scala b/test/files/run/macro-reify-type/Test_2.scala
new file mode 100644
index 0000000000..9beaf98681
--- /dev/null
+++ b/test/files/run/macro-reify-type/Test_2.scala
@@ -0,0 +1,21 @@
+import StaticReflect._
+
+object Test extends App {
+ //println(method[List[Int]]("distinct"))
+ println(method[List[Int]]("map"))
+ //val $u: scala.reflect.runtime.universe.type = scala.reflect.runtime.universe;
+ //val $m: $u.Mirror = scala.reflect.runtime.universe.rootMirror;
+ //import $u._, $m._, Flag._
+ //val tpe = {
+ // val symdef$B2 = build.newNestedSymbol(build.selectTerm(staticClass("scala.collection.TraversableLike"), "map"), newTypeName("B"), NoPosition, DEFERRED | PARAM, false);
+ // val symdef$That2 = build.newNestedSymbol(build.selectTerm(staticClass("scala.collection.TraversableLike"), "map"), newTypeName("That"), NoPosition, DEFERRED | PARAM, false);
+ // val symdef$f2 = build.newNestedSymbol(build.selectTerm(staticClass("scala.collection.TraversableLike"), "map"), newTermName("f"), NoPosition, PARAM, false);
+ // val symdef$bf2 = build.newNestedSymbol(build.selectTerm(staticClass("scala.collection.TraversableLike"), "map"), newTermName("bf"), NoPosition, IMPLICIT | PARAM, false);
+ // build.setTypeSignature(symdef$B2, TypeBounds(staticClass("scala.Nothing").asType.toTypeConstructor, staticClass("scala.Any").asType.toTypeConstructor));
+ // build.setTypeSignature(symdef$That2, TypeBounds(staticClass("scala.Nothing").asType.toTypeConstructor, staticClass("scala.Any").asType.toTypeConstructor));
+ // build.setTypeSignature(symdef$f2, TypeRef(ThisType(staticPackage("scala").asModule.moduleClass), staticClass("scala.Function1"), List(staticClass("scala.Int").asType.toTypeConstructor, TypeRef(NoPrefix, symdef$B2, List()))));
+ // build.setTypeSignature(symdef$bf2, TypeRef(ThisType(staticPackage("scala.collection.generic").asModule.moduleClass), staticClass("scala.collection.generic.CanBuildFrom"), List(TypeRef(ThisType(staticPackage("scala.collection.immutable").asModule.moduleClass), staticClass("scala.collection.immutable.List"), List(staticClass("scala.Int").asType.toTypeConstructor)), TypeRef(NoPrefix, symdef$B2, List()), TypeRef(NoPrefix, symdef$That2, List()))));
+ // PolyType(List(symdef$B2, symdef$That2), MethodType(List(symdef$f2), MethodType(List(symdef$bf2), TypeRef(NoPrefix, symdef$That2, List()))))
+ //}
+ //println(tpe)
+} \ No newline at end of file