Skip to content

Commit 592bd94

Browse files
committed
Eliminate AnnotationTransformer class
This also means that `treeTransformPhase` is now final - every transform transforms its trees at `phase.next`.
1 parent 837f648 commit 592bd94

File tree

2 files changed

+3
-26
lines changed

2 files changed

+3
-26
lines changed

compiler/src/dotty/tools/dotc/transform/ElimRepeated.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import core._
55
import Names._
66
import StdNames.nme
77
import Types._
8-
import dotty.tools.dotc.transform.TreeTransforms.{AnnotationTransformer, TransformerInfo, MiniPhaseTransform, TreeTransformer}
8+
import dotty.tools.dotc.transform.TreeTransforms.{TransformerInfo, MiniPhaseTransform, TreeTransformer}
99
import ast.Trees._
1010
import Flags._
1111
import Contexts.Context

compiler/src/dotty/tools/dotc/transform/TreeTransform.scala

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ object TreeTransforms {
6161

6262
def phase: MiniPhase
6363

64-
def treeTransformPhase: Phase = phase.next
64+
/** The phase at which the tree is transformed */
65+
final def treeTransformPhase: Phase = phase.next
6566

6667
val cpy: TypedTreeCopier = cpyBetweenPhases
6768

@@ -173,30 +174,6 @@ object TreeTransforms {
173174
def phase = this
174175
}
175176

176-
/** A helper trait to transform annotations on MemberDefs */
177-
trait AnnotationTransformer extends MiniPhaseTransform with DenotTransformer {
178-
179-
val annotationTransformer = mkTreeTransformer
180-
override final def treeTransformPhase = this
181-
// need to run at own phase because otherwise we get ahead of ourselves in transforming denotations
182-
183-
abstract override def transform(ref: SingleDenotation)(implicit ctx: Context): SingleDenotation =
184-
super.transform(ref) match {
185-
case ref1: SymDenotation if ref1.symbol.isDefinedInCurrentRun =>
186-
val annots = ref1.annotations
187-
val annotTrees = annots.map(_.tree)
188-
val annotTrees1 = annotTrees.mapConserve(annotationTransformer.macroTransform)
189-
if (annotTrees eq annotTrees1) ref1
190-
else {
191-
val derivedAnnots = (annots, annotTrees1).zipped.map((annot, annotTree1) =>
192-
annot.derivedAnnotation(annotTree1))
193-
ref1.copySymDenotation(annotations = derivedAnnots).copyCaches(ref1, ctx.phase.next)
194-
}
195-
case ref1 =>
196-
ref1
197-
}
198-
}
199-
200177
private class NoTreeTransform extends TreeTransform {
201178
def phase = unsupported("phase")
202179
}

0 commit comments

Comments
 (0)