diff options
author | Martin Odersky <odersky@gmail.com> | 2016-05-20 08:32:39 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-05-23 12:01:39 +0200 |
commit | df58b455df32dbc6cf98eff2ccea6fc268cf6193 (patch) | |
tree | 169f40dbedcf50e7c55a48db1012c2ac369049c0 /src/dotty/tools/dotc/transform/TreeTransform.scala | |
parent | 624561d164c72adfb1a65a2bf55103fe84765915 (diff) | |
download | dotty-df58b455df32dbc6cf98eff2ccea6fc268cf6193.tar.gz dotty-df58b455df32dbc6cf98eff2ccea6fc268cf6193.tar.bz2 dotty-df58b455df32dbc6cf98eff2ccea6fc268cf6193.zip |
Decouple annotation transformers from info transformers
Diffstat (limited to 'src/dotty/tools/dotc/transform/TreeTransform.scala')
-rw-r--r-- | src/dotty/tools/dotc/transform/TreeTransform.scala | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/src/dotty/tools/dotc/transform/TreeTransform.scala b/src/dotty/tools/dotc/transform/TreeTransform.scala index abada9ab4..89ae927b7 100644 --- a/src/dotty/tools/dotc/transform/TreeTransform.scala +++ b/src/dotty/tools/dotc/transform/TreeTransform.scala @@ -174,32 +174,22 @@ object TreeTransforms { } /** A helper trait to transform annotations on MemberDefs */ - trait AnnotationTransformer extends MiniPhaseTransform with InfoTransformer { + trait AnnotationTransformer extends MiniPhaseTransform with DenotTransformer { val annotationTransformer = mkTreeTransformer override final def treeTransformPhase = this // need to run at own phase because otherwise we get ahead of ourselves in transforming denotations - override def transform(ref: SingleDenotation)(implicit ctx: Context): SingleDenotation = { - val info1 = transformInfo(ref.info, ref.symbol) - - ref match { - case ref: SymDenotation => - val annots1 = - if (!ref.symbol.isDefinedInCurrentRun) ref.annotations // leave annotations read from class files alone - else { - val annotTrees = ref.annotations.map(_.tree) - val annotTrees1 = annotTrees.mapConserve(annotationTransformer.macroTransform) - if (annotTrees eq annotTrees1) ref.annotations - else annotTrees1.map(new ConcreteAnnotation(_)) - } - if ((info1 eq ref.info) && (annots1 eq ref.annotations)) ref - else ref.copySymDenotation(info = info1, annotations = annots1) - case _ => - if (info1 eq ref.info) ref - else ref.derivedSingleDenotation(ref.symbol, info1) + abstract override def transform(ref: SingleDenotation)(implicit ctx: Context): SingleDenotation = + super.transform(ref) match { + case ref1: SymDenotation if ref1.symbol.isDefinedInCurrentRun => + val annotTrees = ref1.annotations.map(_.tree) + val annotTrees1 = annotTrees.mapConserve(annotationTransformer.macroTransform) + if (annotTrees eq annotTrees1) ref1 + else ref1.copySymDenotation(annotations = annotTrees1.map(new ConcreteAnnotation(_))) + case ref1 => + ref1 } - } } @sharable val NoTransform = new TreeTransform { |