From 95f74c2a999b20ee5f6ddbe6e14511872e8c227f Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Thu, 1 Jan 2015 14:47:52 +0100 Subject: Provide the correct levels for RefinedThis types. --- src/dotty/tools/dotc/core/TypeOps.scala | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/dotty/tools/dotc/core/TypeOps.scala') 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 -- cgit v1.2.3