aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/TypeOps.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/dotty/tools/dotc/core/TypeOps.scala')
-rw-r--r--src/dotty/tools/dotc/core/TypeOps.scala17
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