@@ -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,33 @@ 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 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
+
28
56
def transformInfo (tp : Type , sym : Symbol )(implicit ctx : Context ): Type =
29
57
elimRepeated(tp)
30
58
0 commit comments