diff options
author | Martin Odersky <odersky@gmail.com> | 2013-11-28 17:08:55 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2013-11-28 17:08:55 +0100 |
commit | 89804e38f3ee6708762609a9b0a9e52544632016 (patch) | |
tree | 61b8ffb17d26ebd713f9d3efe022013ef0b77be7 /src/dotty | |
parent | 76f07f7a5e03ac685270c7af4aa736ca84a00f1f (diff) | |
download | dotty-89804e38f3ee6708762609a9b0a9e52544632016.tar.gz dotty-89804e38f3ee6708762609a9b0a9e52544632016.tar.bz2 dotty-89804e38f3ee6708762609a9b0a9e52544632016.zip |
Making maps configurable so that they can also go inside parents and self types of ClassInfos.
Diffstat (limited to 'src/dotty')
-rw-r--r-- | src/dotty/tools/dotc/core/Types.scala | 17 |
1 files changed, 16 insertions, 1 deletions
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 |