@@ -11,6 +11,7 @@ import Contexts.Context
11
11
import Symbols ._
12
12
import Denotations ._ , SymDenotations ._
13
13
import Decorators .StringInterpolators
14
+ import dotty .tools .dotc .core .Annotations .ConcreteAnnotation
14
15
import scala .collection .mutable
15
16
import DenotTransformers ._
16
17
import Names .Name
@@ -25,6 +26,34 @@ class ElimRepeated extends MiniPhaseTransform with InfoTransformer { thisTransfo
25
26
26
27
override def phaseName = " elimRepeated"
27
28
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
+
28
57
def transformInfo (tp : Type , sym : Symbol )(implicit ctx : Context ): Type =
29
58
elimRepeated(tp)
30
59
0 commit comments