diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2014-01-28 19:37:59 +0300 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2014-02-14 14:19:44 +0100 |
commit | 0268e03cb461b0c7e8ae2082894988395fc0994a (patch) | |
tree | 7dec4c177aad62a2209601a0f5327e243c3340b2 /src/compiler | |
parent | c7fd03900b7023967f22932f1f32b98d57983e9b (diff) | |
download | scala-0268e03cb461b0c7e8ae2082894988395fc0994a.tar.gz scala-0268e03cb461b0c7e8ae2082894988395fc0994a.tar.bz2 scala-0268e03cb461b0c7e8ae2082894988395fc0994a.zip |
SI-8118 simplifies Annotation down to a plain Tree
As per https://groups.google.com/forum/#!topic/scala-internals/8v2UL-LR9yY,
annotations don’t have to be represented as AnnotationInfos and can be
reduced to plain Trees.
Due to compatibility reasons and because of the limitations of the cake
pattern used in implementing current version of Reflection, we can’t
just say `type Annotation = Tree`, however what we can definitely do is
to deprecate all the methods on Annotation and expose `tree: Tree` instead.
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/reflect/reify/codegen/GenAnnotationInfos.scala | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/src/compiler/scala/reflect/reify/codegen/GenAnnotationInfos.scala b/src/compiler/scala/reflect/reify/codegen/GenAnnotationInfos.scala index bd60faf4cd..ce26232e5f 100644 --- a/src/compiler/scala/reflect/reify/codegen/GenAnnotationInfos.scala +++ b/src/compiler/scala/reflect/reify/codegen/GenAnnotationInfos.scala @@ -38,19 +38,10 @@ trait GenAnnotationInfos { } } - def reifyClassfileAnnotArg(arg: ClassfileAnnotArg): Tree = arg match { - case LiteralAnnotArg(const) => - mirrorFactoryCall(nme.LiteralAnnotArg, reifyProduct(const)) - case ArrayAnnotArg(args) => - mirrorFactoryCall(nme.ArrayAnnotArg, scalaFactoryCall(nme.Array, args map reifyClassfileAnnotArg: _*)) - case NestedAnnotArg(ann) => - mirrorFactoryCall(nme.NestedAnnotArg, reifyAnnotationInfo(ann)) - case _ => - sys.error(s"Don't know what to do with $arg") - } - // if you reify originals of anns, you get SO when trying to reify AnnotatedTypes, so screw it - after all, it's not that important - val reifiedAssocs = ann.assocs map (assoc => scalaFactoryCall(nme.Tuple2, reify(assoc._1), reifyClassfileAnnotArg(assoc._2))) - mirrorFactoryCall(nme.Annotation, reify(ann.atp), mkList(reifiedArgs), mkListMap(reifiedAssocs)) + val Apply(Select(New(tpt), name), args) = annotationToTree(ann) + val reifiedAtp = mirrorCall(nme.Select, mirrorCall(nme.New, mirrorCall(nme.TypeTree, reifyType(tpt.tpe))), reify(name)) + val reifiedAnnRepr = mirrorCall(nme.Apply, reifiedAtp, reifyList(args)) + mirrorFactoryCall(nme.Annotation, reifiedAnnRepr) } } |