diff options
author | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2014-10-11 12:21:12 +0200 |
---|---|---|
committer | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2014-11-22 20:10:19 +0100 |
commit | cda5addb0e4fca124e0cedcb80237dd7f39ac0b7 (patch) | |
tree | d9ecb0613ba7b952b38aa1d56add1d45bc99ffec /src/dotty/tools/dotc/transform/ElimRepeated.scala | |
parent | 9760fb7bbb5ceaeba98b6625470bd9f03755a31d (diff) | |
download | dotty-cda5addb0e4fca124e0cedcb80237dd7f39ac0b7.tar.gz dotty-cda5addb0e4fca124e0cedcb80237dd7f39ac0b7.tar.bz2 dotty-cda5addb0e4fca124e0cedcb80237dd7f39ac0b7.zip |
Fix elimRepeated not transforming annotations.
Diffstat (limited to 'src/dotty/tools/dotc/transform/ElimRepeated.scala')
-rw-r--r-- | src/dotty/tools/dotc/transform/ElimRepeated.scala | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/dotty/tools/dotc/transform/ElimRepeated.scala b/src/dotty/tools/dotc/transform/ElimRepeated.scala index 03fd28a26..7f2492d3c 100644 --- a/src/dotty/tools/dotc/transform/ElimRepeated.scala +++ b/src/dotty/tools/dotc/transform/ElimRepeated.scala @@ -11,6 +11,7 @@ import Contexts.Context import Symbols._ import Denotations._, SymDenotations._ import Decorators.StringInterpolators +import dotty.tools.dotc.core.Annotations.ConcreteAnnotation import scala.collection.mutable import DenotTransformers._ import Names.Name @@ -25,6 +26,34 @@ class ElimRepeated extends MiniPhaseTransform with InfoTransformer { thisTransfo override def phaseName = "elimRepeated" + object annotTransformer extends TreeMap { + override def transform(tree: Tree)(implicit ctx: Context): Tree = super.transform(tree) match { + case x @(_: Ident|_ :Select|_: Apply| _: TypeApply| _: DefDef) => transformTypeOfTree(x) + case x => x + } + } + + /** + * Overriden to solve a particular problem with <repeated> not being eliminated inside annotation trees + * Dmitry: this should solve problem for now, + * following YAGNI principle I am convinced that we shouldn't make a solution + * for a generalized problem(transforming annotations trees) + * that manifests itself only here. + */ + override def transform(ref: SingleDenotation)(implicit ctx: Context): SingleDenotation = { + val info1 = transformInfo(ref.info, ref.symbol) + + ref match { + case ref: SymDenotation => + val annotTrees = ref.annotations.map(_.tree) + val annotTrees1 = annotTrees.mapConserve(annotTransformer.transform) + val annots1 = if(annotTrees eq annotTrees1) ref.annotations else annotTrees1.map(new ConcreteAnnotation(_)) + if ((info1 eq ref.info) && (annots1 eq ref.annotations)) ref + else ref.copySymDenotation(info = info1, annotations = annots1) + case _ => if (info1 eq ref.info) ref else ref.derivedSingleDenotation(ref.symbol, info1) + } + } + def transformInfo(tp: Type, sym: Symbol)(implicit ctx: Context): Type = elimRepeated(tp) |