aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/Types.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/dotty/tools/dotc/core/Types.scala')
-rw-r--r--src/dotty/tools/dotc/core/Types.scala17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala
index cba13ef81..42abc4251 100644
--- a/src/dotty/tools/dotc/core/Types.scala
+++ b/src/dotty/tools/dotc/core/Types.scala
@@ -2191,16 +2191,20 @@ object Types {
}
object RecType {
+ /* Note: this might well fail for nested Recs.
+ * Failing scenario: Rebind a nest rec, creates a new rec
+ * but it still has RecThis references to the outer rec.
def checkInst(tp: Type)(implicit ctx: Context): tp.type = {
var binders: List[RecType] = Nil
tp.foreachPart {
case rt: RecType => binders = rt :: binders
- case rt: RecThis => assert(binders contains rt.binder, tp)
+ case rt: RecThis => assert(binders contains rt.binder)
case _ =>
}
tp
}
- def apply(parentExp: RecType => Type)(implicit ctx: Context): RecType = checkInst {
+ */
+ def apply(parentExp: RecType => Type)(implicit ctx: Context): RecType = {
var rt = new RecType(parentExp)
rt.parent match {
case rt2: RecType =>
@@ -2209,14 +2213,9 @@ object Types {
}
unique(rt)
}
- def closeOver(parentExp: RecType => Type)(implicit ctx: Context) = checkInst {
+ def closeOver(parentExp: RecType => Type)(implicit ctx: Context) = {
val rt = this(parentExp)
- //val self = RecThis(rt)
- def isSelfRef(t: Type) = t match {
- case RecThis(binder) => binder eq rt
- case _ => false
- }
- if (rt.existsPart(isSelfRef)) rt else rt.parent
+ if (rt.isReferredToBy(rt.parent)) rt else rt.parent
}
}