From fe714ed2b6aaca41f1e6681b217022b301f3049d Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Thu, 23 Jul 2015 17:42:55 +0200 Subject: Change some occurrences of <:< to frozen_<:< Some subtype tests should not instantiate type variables, in particular those having to do with & and |. --- src/dotty/tools/dotc/core/Denotations.scala | 4 ++-- src/dotty/tools/dotc/core/TypeApplications.scala | 4 ++-- src/dotty/tools/dotc/core/Types.scala | 17 +++++++++++------ 3 files changed, 15 insertions(+), 10 deletions(-) (limited to 'src/dotty/tools') diff --git a/src/dotty/tools/dotc/core/Denotations.scala b/src/dotty/tools/dotc/core/Denotations.scala index fff447803..b223a8086 100644 --- a/src/dotty/tools/dotc/core/Denotations.scala +++ b/src/dotty/tools/dotc/core/Denotations.scala @@ -339,8 +339,8 @@ object Denotations { val info1 = denot1.info val info2 = denot2.info val sameSym = sym1 eq sym2 - if (sameSym && info1 <:< info2) denot2 - else if (sameSym && info2 <:< info1) denot1 + if (sameSym && (info1 frozen_<:< info2)) denot2 + else if (sameSym && (info2 frozen_<:< info1)) denot1 else { val jointSym = if (sameSym) sym1 diff --git a/src/dotty/tools/dotc/core/TypeApplications.scala b/src/dotty/tools/dotc/core/TypeApplications.scala index 927c4fcc5..47935f79e 100644 --- a/src/dotty/tools/dotc/core/TypeApplications.scala +++ b/src/dotty/tools/dotc/core/TypeApplications.scala @@ -497,7 +497,7 @@ class TypeApplications(val self: Type) extends AnyVal { val boundss = new mutable.ListBuffer[TypeBounds] for (sym <- boundSyms) { val bounds = sym.info.bounds - if (!(TypeBounds.empty <:< bounds)) { + if (!(TypeBounds.empty frozen_<:< bounds)) { boundNames += sym.name boundss += bounds } @@ -574,7 +574,7 @@ class TypeApplications(val self: Type) extends AnyVal { // we have a binding T = Lambda$XYZ{...}.this.hk$i where hk$i names the current `tparam`. val pcore = etaCore(tp.parent, otherParams) val hkBounds = self.member(rname).info.bounds - if (TypeBounds.empty <:< hkBounds) pcore + if (TypeBounds.empty frozen_<:< hkBounds) pcore else tp.derivedRefinedType(pcore, tp.refinedName, hkBounds) case _ => val pcore = etaCore(tp.parent, tparams) 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 { -- cgit v1.2.3