diff options
author | Martin Odersky <odersky@gmail.com> | 2015-07-23 17:42:55 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2015-10-01 19:33:25 +0200 |
commit | fe714ed2b6aaca41f1e6681b217022b301f3049d (patch) | |
tree | 07984582b64af2709b40e10a967da532ae6d0255 /src/dotty/tools/dotc/core/Types.scala | |
parent | 78239daf86cf6d45fec46f259e55e1fdbd963046 (diff) | |
download | dotty-fe714ed2b6aaca41f1e6681b217022b301f3049d.tar.gz dotty-fe714ed2b6aaca41f1e6681b217022b301f3049d.tar.bz2 dotty-fe714ed2b6aaca41f1e6681b217022b301f3049d.zip |
Change some occurrences of <:< to frozen_<:<
Some subtype tests should not instantiate type variables, in particular
those having to do with & and |.
Diffstat (limited to 'src/dotty/tools/dotc/core/Types.scala')
-rw-r--r-- | src/dotty/tools/dotc/core/Types.scala | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index bce57ae23..8ad694ea2 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -595,6 +595,11 @@ object Types { ctx.typeComparer.topLevelSubType(this, that) } + /** Is this type a subtype of that type? */ + final def frozen_<:<(that: Type)(implicit ctx: Context): Boolean = track("frozen_<:<") { + ctx.typeComparer.isSubTypeWhenFrozen(this, that) + } + /** Is this type the same as that type? * This is the case iff `this <:< that` and `that <:< this`. */ @@ -625,9 +630,9 @@ object Types { case ExprType(_) | MethodType(Nil, _) => tp.resultType case _ => tp } - this <:< that || { + (this frozen_<:< that) || { val rthat = result(that) - (rthat ne that) && result(this) <:< rthat + (rthat ne that) && (result(this) frozen_<:< rthat) } } @@ -2652,13 +2657,13 @@ object Types { } def & (that: TypeBounds)(implicit ctx: Context): TypeBounds = - if (this.lo <:< that.lo && that.hi <:< this.hi) that - else if (that.lo <:< this.lo && this.hi <:< that.hi) this + if ((this.lo frozen_<:< that.lo) && (that.hi frozen_<:< this.hi)) that + else if ((that.lo frozen_<:< this.lo) && (this.hi frozen_<:< that.hi)) this else TypeBounds(this.lo | that.lo, this.hi & that.hi) def | (that: TypeBounds)(implicit ctx: Context): TypeBounds = - if (this.lo <:< that.lo && that.hi <:< this.hi) this - else if (that.lo <:< this.lo && this.hi <:< that.hi) that + if ((this.lo frozen_<:< that.lo) && (that.hi frozen_<:< this.hi)) this + else if ((that.lo frozen_<:< this.lo) && (this.hi frozen_<:< that.hi)) that else TypeBounds(this.lo & that.lo, this.hi | that.hi) override def & (that: Type)(implicit ctx: Context) = that match { |