diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2013-07-11 12:15:35 +1000 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2013-07-11 16:48:23 +1000 |
commit | 6368ae7218c0af651f74a566f718a8b03a547ba2 (patch) | |
tree | 9348318629c243a120c8c3ab39100c6e05b90628 /src/compiler/scala/reflect/reify/phases/Reshape.scala | |
parent | 54cb6af7dbcf630a4f57e98f0099d77dd3b36693 (diff) | |
download | scala-6368ae7218c0af651f74a566f718a8b03a547ba2.tar.gz scala-6368ae7218c0af651f74a566f718a8b03a547ba2.tar.bz2 scala-6368ae7218c0af651f74a566f718a8b03a547ba2.zip |
SI-7649 Fix positions for reshaped tag materializers
Calls to `materializeClassTag[T]` are replaced during reification with
`implicitly[ClassTag[T]]` in the `reify` macro. This is done to avoid
referring to symbols in scala-compiler.jar. Class- and Type-Tag
materialization is treated in the same way.
This commit positions the replacement trees to avoid triggering
assertions under -Yrangepos.
Diffstat (limited to 'src/compiler/scala/reflect/reify/phases/Reshape.scala')
-rw-r--r-- | src/compiler/scala/reflect/reify/phases/Reshape.scala | 16 |
1 files changed, 8 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 } |