From 103beef6ab89d6138ec7462fcf85ee3f93cf2b52 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 14 Apr 2014 14:38:57 +0200 Subject: InfoTransformers as specific DenotTransformers Factored out denot transformer behavior where the we transform types in a uniform way into InfoTransformers. --- src/dotty/tools/dotc/core/DenotTransformers.scala | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/dotty/tools/dotc/core/DenotTransformers.scala') 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) + } + } + } } -- cgit v1.2.3