diff options
author | Martin Odersky <odersky@gmail.com> | 2016-06-29 19:06:13 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-07-11 13:34:59 +0200 |
commit | aa7f66d3f7d299733158a08bad5ac0d746497d81 (patch) | |
tree | 5e13f72b97c0971bf789edff2f8d93dc9af81b71 /src/dotty/tools/dotc/core | |
parent | af43d325b778973ad9e144b5c27c455febb98890 (diff) | |
download | dotty-aa7f66d3f7d299733158a08bad5ac0d746497d81.tar.gz dotty-aa7f66d3f7d299733158a08bad5ac0d746497d81.tar.bz2 dotty-aa7f66d3f7d299733158a08bad5ac0d746497d81.zip |
Disable checkInst in RecType
It can give false negatives.
Also, simplify RecType.closeOver
Diffstat (limited to 'src/dotty/tools/dotc/core')
-rw-r--r-- | src/dotty/tools/dotc/core/Types.scala | 17 |
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 } } |