diff options
author | Martin Odersky <odersky@gmail.com> | 2015-01-01 14:47:52 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2015-01-01 14:49:33 +0100 |
commit | 95f74c2a999b20ee5f6ddbe6e14511872e8c227f (patch) | |
tree | 40ff60221d4a9e9ba8b9a4ea01b11eec036903a2 /src/dotty/tools/dotc/core/TypeOps.scala | |
parent | e3a43806a2b5b17982e942a82cabe139c09d971e (diff) | |
download | dotty-95f74c2a999b20ee5f6ddbe6e14511872e8c227f.tar.gz dotty-95f74c2a999b20ee5f6ddbe6e14511872e8c227f.tar.bz2 dotty-95f74c2a999b20ee5f6ddbe6e14511872e8c227f.zip |
Provide the correct levels for RefinedThis types.
Diffstat (limited to 'src/dotty/tools/dotc/core/TypeOps.scala')
-rw-r--r-- | src/dotty/tools/dotc/core/TypeOps.scala | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/core/TypeOps.scala b/src/dotty/tools/dotc/core/TypeOps.scala index 260e2f6d6..88f495f47 100644 --- a/src/dotty/tools/dotc/core/TypeOps.scala +++ b/src/dotty/tools/dotc/core/TypeOps.scala @@ -330,7 +330,22 @@ trait TypeOps { this: Context => } parentRefs } - + + /** Map `C.this` types where `C` is `refineCls` to RefinedThis types with given level. + * The level gets adjusted for nested refined types. + */ + def thisToRefinedThis(rt: RefinedType, refineCls: Symbol, level: Int): TypeMap = new TypeMap { + def apply(tp: Type): Type = tp match { + case tp: ThisType if tp.cls eq refineCls => RefinedThis(rt, level) + case tp: RefinedType => + tp.derivedRefinedType( + this(tp.parent), tp.refinedName, + thisToRefinedThis(rt, refineCls, level + 1)(tp.refinedInfo)) + case _ => + mapOver(tp) + } + } + /** An argument bounds violation is a triple consisting of * - the argument tree * - a string "upper" or "lower" indicating which bound is violated |