From aa7f66d3f7d299733158a08bad5ac0d746497d81 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Wed, 29 Jun 2016 19:06:13 +0200 Subject: Disable checkInst in RecType It can give false negatives. Also, simplify RecType.closeOver --- src/dotty/tools/dotc/core/Types.scala | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src/dotty/tools/dotc/core/Types.scala') 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 } } -- cgit v1.2.3