aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/DenotTransformers.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-04-14 14:38:57 +0200
committerMartin Odersky <odersky@gmail.com>2014-04-14 15:55:15 +0200
commit103beef6ab89d6138ec7462fcf85ee3f93cf2b52 (patch)
tree53f70b63ca4419c135c2b9f86b4ba96462eeed10 /src/dotty/tools/dotc/core/DenotTransformers.scala
parentf39b6249a11cdb35445da8ce0a338911af496695 (diff)
downloaddotty-103beef6ab89d6138ec7462fcf85ee3f93cf2b52.tar.gz
dotty-103beef6ab89d6138ec7462fcf85ee3f93cf2b52.tar.bz2
dotty-103beef6ab89d6138ec7462fcf85ee3f93cf2b52.zip
InfoTransformers as specific DenotTransformers
Factored out denot transformer behavior where the we transform types in a uniform way into InfoTransformers.
Diffstat (limited to 'src/dotty/tools/dotc/core/DenotTransformers.scala')
-rw-r--r--src/dotty/tools/dotc/core/DenotTransformers.scala16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/dotty/tools/dotc/core/DenotTransformers.scala b/src/dotty/tools/dotc/core/DenotTransformers.scala
index e1ee355d8..6daa028fc 100644
--- a/src/dotty/tools/dotc/core/DenotTransformers.scala
+++ b/src/dotty/tools/dotc/core/DenotTransformers.scala
@@ -5,6 +5,7 @@ import Periods._
import SymDenotations._
import Contexts._
import Types._
+import Symbols._
import Denotations._
import Phases._
import java.lang.AssertionError
@@ -30,4 +31,19 @@ object DenotTransformers {
/** The transformation method */
def transform(ref: SingleDenotation)(implicit ctx: Context): SingleDenotation
}
+
+ trait InfoTransformer extends DenotTransformer {
+
+ def transformInfo(tp: Type, sym: Symbol)(implicit ctx: Context): Type
+
+ /** The transformation method */
+ def transform(ref: SingleDenotation)(implicit ctx: Context): SingleDenotation = {
+ val info1 = transformInfo(ref.info, ref.symbol)
+ if (info1 eq ref.info) ref
+ else ref match {
+ case ref: SymDenotation => ref.copySymDenotation(info = info1)
+ case _ => ref.derivedSingleDenotation(ref.symbol, info1)
+ }
+ }
+ }
}