From 89804e38f3ee6708762609a9b0a9e52544632016 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Thu, 28 Nov 2013 17:08:55 +0100 Subject: Making maps configurable so that they can also go inside parents and self types of ClassInfos. --- src/dotty/tools/dotc/core/Types.scala | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index aba462456..1f1560603 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -1978,6 +1978,12 @@ object Types { // ----- TypeMaps -------------------------------------------------------------------- abstract class TypeMap(implicit ctx: Context) extends (Type => Type) { thisMap => + + /** Unset by default. If set also map parents and self type of a ClassInfo. + * By default, only the prefix is mapped. + */ + def mapClassInfosDeeply = false + def apply(tp: Type): Type /** Map this function over given type */ @@ -2013,7 +2019,16 @@ object Types { } case tp @ ClassInfo(prefix, _, _, _, _) => - tp.derivedClassInfo(this(prefix)) + if (mapClassInfosDeeply) { + val prefix1 = this(prefix) + val parents1 = (tp.parents mapConserve this).asInstanceOf[List[TypeRef]] + val self1 = tp.self match { + case self: Type => this(self) + case _ => tp.self + } + tp.derivedClassInfo(prefix1, parents1, self1) + } + else tp.derivedClassInfo(this(prefix)) case tp: TypeVar => val inst = tp.instanceOpt -- cgit v1.2.3