summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@typesafe.com>2013-07-12 12:00:45 -0700
committerAdriaan Moors <adriaan.moors@typesafe.com>2013-07-12 12:00:45 -0700
commit8bcb848fd2d00eabe224a9dd6384dbf19d76ce9f (patch)
tree1d1ab95e4be5d42e41cc5523c9a304770e131e41
parent731d41ac87c2ae797c9dcd2b420712b00b802c66 (diff)
parent6368ae7218c0af651f74a566f718a8b03a547ba2 (diff)
downloadscala-8bcb848fd2d00eabe224a9dd6384dbf19d76ce9f.tar.gz
scala-8bcb848fd2d00eabe224a9dd6384dbf19d76ce9f.tar.bz2
scala-8bcb848fd2d00eabe224a9dd6384dbf19d76ce9f.zip
Merge pull request #2721 from retronym/ticket/7649
SI-7649 Fix positions for reshaped tag materializers
-rw-r--r--src/compiler/scala/reflect/reify/phases/Reshape.scala16
-rw-r--r--test/files/pos/t7649.flags1
-rw-r--r--test/files/pos/t7649.scala20
3 files changed, 29 insertions, 8 deletions
diff --git a/src/compiler/scala/reflect/reify/phases/Reshape.scala b/src/compiler/scala/reflect/reify/phases/Reshape.scala
index a320718084..535a933c73 100644
--- a/src/compiler/scala/reflect/reify/phases/Reshape.scala
+++ b/src/compiler/scala/reflect/reify/phases/Reshape.scala
@@ -91,20 +91,20 @@ trait Reshape {
private def undoMacroExpansion(tree: Tree): Tree =
tree.attachments.get[MacroExpansionAttachment] match {
case Some(MacroExpansionAttachment(original)) =>
+ def mkImplicitly(tp: Type) = atPos(tree.pos)(
+ gen.mkNullaryCall(Predef_implicitly, List(tp))
+ )
+ val sym = original.symbol
original match {
// this hack is necessary until I fix implicit macros
// so far tag materialization is implemented by sneaky macros hidden in scala-compiler.jar
// hence we cannot reify references to them, because noone will be able to see them later
// when implicit macros are fixed, these sneaky macros will move to corresponding companion objects
// of, say, ClassTag or TypeTag
- case Apply(TypeApply(_, List(tt)), _) if original.symbol == materializeClassTag =>
- gen.mkNullaryCall(Predef_implicitly, List(appliedType(ClassTagClass, tt.tpe)))
- case Apply(TypeApply(_, List(tt)), List(pre)) if original.symbol == materializeWeakTypeTag =>
- gen.mkNullaryCall(Predef_implicitly, List(typeRef(pre.tpe, WeakTypeTagClass, List(tt.tpe))))
- case Apply(TypeApply(_, List(tt)), List(pre)) if original.symbol == materializeTypeTag =>
- gen.mkNullaryCall(Predef_implicitly, List(typeRef(pre.tpe, TypeTagClass, List(tt.tpe))))
- case _ =>
- original
+ case Apply(TypeApply(_, List(tt)), _) if sym == materializeClassTag => mkImplicitly(appliedType(ClassTagClass, tt.tpe))
+ case Apply(TypeApply(_, List(tt)), List(pre)) if sym == materializeWeakTypeTag => mkImplicitly(typeRef(pre.tpe, WeakTypeTagClass, List(tt.tpe)))
+ case Apply(TypeApply(_, List(tt)), List(pre)) if sym == materializeTypeTag => mkImplicitly(typeRef(pre.tpe, TypeTagClass, List(tt.tpe)))
+ case _ => original
}
case _ => tree
}
diff --git a/test/files/pos/t7649.flags b/test/files/pos/t7649.flags
new file mode 100644
index 0000000000..fcf951d907
--- /dev/null
+++ b/test/files/pos/t7649.flags
@@ -0,0 +1 @@
+-Yrangepos \ No newline at end of file
diff --git a/test/files/pos/t7649.scala b/test/files/pos/t7649.scala
new file mode 100644
index 0000000000..a1b02f63f1
--- /dev/null
+++ b/test/files/pos/t7649.scala
@@ -0,0 +1,20 @@
+object Test {
+ val c: reflect.macros.Context = ???
+ import c.universe._
+ reify {
+ // The lookup of the implicit WeakTypeTag[Any]
+ // was triggering an unpositioned tree.
+ c.Expr[Any](Literal(Constant(0))).splice
+ }
+
+ import scala.reflect.ClassTag
+ def ct[A: ClassTag]: Expr[A] = ???
+ def tt[A: TypeTag]: Expr[A] = ???
+ def wtt[A: WeakTypeTag]: Expr[A] = ???
+
+ reify {
+ ct[String].splice
+ tt[String].splice
+ wtt[String].splice
+ }
+}