@@ -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,33 @@ 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 don't want to make a solution not having observed other manifestations of this
40+ * problem
41+ */
42+ override def transform (ref : SingleDenotation )(implicit ctx : Context ): SingleDenotation = {
43+ val info1 = transformInfo(ref.info, ref.symbol)
44+
45+ ref match {
46+ case ref : SymDenotation =>
47+ val annotTrees = ref.annotations.map(_.tree)
48+ val annotTrees1 = annotTrees.mapConserve(annotTransformer.transform)
49+ val annots1 = if (annotTrees eq annotTrees1) ref.annotations else annotTrees1.map(new ConcreteAnnotation (_))
50+ if ((info1 eq ref.info) && (annots1 eq ref.annotations)) ref
51+ else ref.copySymDenotation(info = info1, annotations = annots1)
52+ case _ => if (info1 eq ref.info) ref else ref.derivedSingleDenotation(ref.symbol, info1)
53+ }
54+ }
55+
2856 def transformInfo (tp : Type , sym : Symbol )(implicit ctx : Context ): Type =
2957 elimRepeated(tp)
3058
0 commit comments