aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-05-20 08:32:39 +0200
committerMartin Odersky <odersky@gmail.com>2016-05-23 12:01:39 +0200
commitdf58b455df32dbc6cf98eff2ccea6fc268cf6193 (patch)
tree169f40dbedcf50e7c55a48db1012c2ac369049c0 /src
parent624561d164c72adfb1a65a2bf55103fe84765915 (diff)
downloaddotty-df58b455df32dbc6cf98eff2ccea6fc268cf6193.tar.gz
dotty-df58b455df32dbc6cf98eff2ccea6fc268cf6193.tar.bz2
dotty-df58b455df32dbc6cf98eff2ccea6fc268cf6193.zip
Decouple annotation transformers from info transformers
Diffstat (limited to 'src')
-rw-r--r--src/dotty/tools/dotc/transform/CheckReentrant.scala2
-rw-r--r--src/dotty/tools/dotc/transform/CheckStatic.scala2
-rw-r--r--src/dotty/tools/dotc/transform/FirstTransform.scala7
-rw-r--r--src/dotty/tools/dotc/transform/TreeTransform.scala30
4 files changed, 16 insertions, 25 deletions
diff --git a/src/dotty/tools/dotc/transform/CheckReentrant.scala b/src/dotty/tools/dotc/transform/CheckReentrant.scala
index 2569b3aae..7e0e368b5 100644
--- a/src/dotty/tools/dotc/transform/CheckReentrant.scala
+++ b/src/dotty/tools/dotc/transform/CheckReentrant.scala
@@ -3,7 +3,7 @@ package transform
import core._
import Names._
-import dotty.tools.dotc.transform.TreeTransforms.{AnnotationTransformer, TransformerInfo, MiniPhaseTransform, TreeTransformer}
+import dotty.tools.dotc.transform.TreeTransforms.{TransformerInfo, MiniPhaseTransform, TreeTransformer}
import ast.Trees._
import Flags._
import Types._
diff --git a/src/dotty/tools/dotc/transform/CheckStatic.scala b/src/dotty/tools/dotc/transform/CheckStatic.scala
index 445e9f839..77c6dfc51 100644
--- a/src/dotty/tools/dotc/transform/CheckStatic.scala
+++ b/src/dotty/tools/dotc/transform/CheckStatic.scala
@@ -5,7 +5,7 @@ import core._
import Names._
import StdNames.nme
import Types._
-import dotty.tools.dotc.transform.TreeTransforms.{AnnotationTransformer, TransformerInfo, MiniPhaseTransform, TreeTransformer}
+import dotty.tools.dotc.transform.TreeTransforms.{TransformerInfo, MiniPhaseTransform, TreeTransformer}
import ast.Trees._
import Flags._
import Contexts.Context
diff --git a/src/dotty/tools/dotc/transform/FirstTransform.scala b/src/dotty/tools/dotc/transform/FirstTransform.scala
index ae72d5f6c..6e1fed607 100644
--- a/src/dotty/tools/dotc/transform/FirstTransform.scala
+++ b/src/dotty/tools/dotc/transform/FirstTransform.scala
@@ -30,7 +30,7 @@ import StdNames._
* - stubs out native methods
* - eliminate self tree in Template and self symbol in ClassInfo
*/
-class FirstTransform extends MiniPhaseTransform with IdentityDenotTransformer with AnnotationTransformer { thisTransformer =>
+class FirstTransform extends MiniPhaseTransform with InfoTransformer with AnnotationTransformer { thisTransformer =>
import ast.tpd._
override def phaseName = "firstTransform"
@@ -46,12 +46,13 @@ class FirstTransform extends MiniPhaseTransform with IdentityDenotTransformer wi
}
/** eliminate self symbol in ClassInfo */
- def transformInfo(tp: Type, sym: Symbol)(implicit ctx: Context): Type = tp match {
- case tp@ClassInfo(_, _, _, _, self: Symbol) =>
+ override def transformInfo(tp: Type, sym: Symbol)(implicit ctx: Context): Type = tp match {
+ case tp @ ClassInfo(_, _, _, _, self: Symbol) =>
tp.derivedClassInfo(selfInfo = self.info)
case _ =>
tp
}
+
/*
tp match {
//create companions for value classes that are not from currently compiled source file
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 {