@@ -11,6 +11,7 @@ import Contexts.Context
1111import Symbols ._
1212import Denotations ._ , SymDenotations ._
1313import Decorators .StringInterpolators
14+ import dotty .tools .dotc .core .Annotations .ConcreteAnnotation
1415import scala .collection .mutable
1516import DenotTransformers ._
1617import Names .Name
@@ -25,6 +26,34 @@ class ElimRepeated extends MiniPhaseTransform with InfoTransformer { thisTransfo
2526
2627 override def phaseName = " elimRepeated"
2728
29+ object annotTransformer extends TreeMap {
30+ override def transform (tree : Tree )(implicit ctx : Context ): Tree = super .transform(tree) match {
31+ case x @ (_ : Ident | _ : Select | _ : Apply | _ : TypeApply | _ : DefDef ) => transformTypeOfTree(x)
32+ case x => x
33+ }
34+ }
35+
36+ /**
37+ * Overriden to solve a particular problem with <repeated> not being eliminated inside annotation trees
38+ * Dmitry: this should solve problem for now,
39+ * following YAGNI principle I am convinced that we shouldn't make a solution
40+ * for a generalized problem(transforming annotations trees)
41+ * that manifests itself only here.
42+ */
43+ override def transform (ref : SingleDenotation )(implicit ctx : Context ): SingleDenotation = {
44+ val info1 = transformInfo(ref.info, ref.symbol)
45+
46+ ref match {
47+ case ref : SymDenotation =>
48+ val annotTrees = ref.annotations.map(_.tree)
49+ val annotTrees1 = annotTrees.mapConserve(annotTransformer.transform)
50+ val annots1 = if (annotTrees eq annotTrees1) ref.annotations else annotTrees1.map(new ConcreteAnnotation (_))
51+ if ((info1 eq ref.info) && (annots1 eq ref.annotations)) ref
52+ else ref.copySymDenotation(info = info1, annotations = annots1)
53+ case _ => if (info1 eq ref.info) ref else ref.derivedSingleDenotation(ref.symbol, info1)
54+ }
55+ }
56+
2857 def transformInfo (tp : Type , sym : Symbol )(implicit ctx : Context ): Type =
2958 elimRepeated(tp)
3059
0 commit comments