Skip to content

Commit 4a4b310

Browse files
committed
Revert TypeBounds.real to TypeBounds.apply
TypeBounds.real served its purpose: Flushing out all problems with creating TypeBounds.
1 parent 916fe1b commit 4a4b310

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/dotty/tools/dotc/core/TypeComparer.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ class TypeComparer(initctx: Context) extends DotClass {
619619
case TypeBounds(lo1, hi1) =>
620620
if ((ctx.mode is Mode.GADTflexible) && (tp1.symbol is GADTFlexType) &&
621621
!isSubTypeWhenFrozen(hi1, tp2))
622-
trySetType(tp1, TypeBounds.real(lo1, hi1 & tp2))
622+
trySetType(tp1, TypeBounds(lo1, hi1 & tp2))
623623
else if (lo1 eq hi1) isSubType(hi1, tp2)
624624
else tryRebase2nd
625625
case _ =>
@@ -638,7 +638,7 @@ class TypeComparer(initctx: Context) extends DotClass {
638638
case TypeBounds(lo2, hi2) =>
639639
if ((ctx.mode is Mode.GADTflexible) && (tp2.symbol is GADTFlexType) &&
640640
!isSubTypeWhenFrozen(tp1, lo2))
641-
trySetType(tp2, TypeBounds.real(lo2 | tp1, hi2))
641+
trySetType(tp2, TypeBounds(lo2 | tp1, hi2))
642642
else
643643
((frozenConstraint || !isCappable(tp1)) && isSubType(tp1, lo2)
644644
|| tryRebase3rd)

src/dotty/tools/dotc/core/Types.scala

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2398,10 +2398,10 @@ object Types {
23982398

23992399
override def underlying(implicit ctx: Context): Type = hi
24002400

2401-
/** The non-variant type bounds or alias type with given bounds */
2401+
/** The non-alias type bounds type with given bounds */
24022402
def derivedTypeBounds(lo: Type, hi: Type)(implicit ctx: Context) =
24032403
if ((lo eq this.lo) && (hi eq this.hi) && (variance == 0)) this
2404-
else TypeBounds.real(lo, hi)
2404+
else TypeBounds(lo, hi)
24052405

24062406
/** If this is an alias, a derived alias with the new variance,
24072407
* Otherwise the type itself.
@@ -2419,12 +2419,12 @@ object Types {
24192419
def & (that: TypeBounds)(implicit ctx: Context): TypeBounds =
24202420
if (this.lo <:< that.lo && that.hi <:< this.hi) that
24212421
else if (that.lo <:< this.lo && this.hi <:< that.hi) this
2422-
else TypeBounds.real(this.lo | that.lo, this.hi & that.hi)
2422+
else TypeBounds(this.lo | that.lo, this.hi & that.hi)
24232423

24242424
def | (that: TypeBounds)(implicit ctx: Context): TypeBounds =
24252425
if (this.lo <:< that.lo && that.hi <:< this.hi) this
24262426
else if (that.lo <:< this.lo && this.hi <:< that.hi) that
2427-
else TypeBounds.real(this.lo & that.lo, this.hi | that.hi)
2427+
else TypeBounds(this.lo & that.lo, this.hi | that.hi)
24282428

24292429
override def & (that: Type)(implicit ctx: Context) = that match {
24302430
case that: TypeBounds => this & that
@@ -2481,14 +2481,14 @@ object Types {
24812481
}
24822482

24832483
object TypeBounds {
2484-
def real(lo: Type, hi: Type)(implicit ctx: Context): TypeBounds =
2484+
def apply(lo: Type, hi: Type)(implicit ctx: Context): TypeBounds =
24852485
unique(new RealTypeBounds(lo, hi))
24862486
def orAlias(lo: Type, hi: Type)(implicit ctx: Context): TypeBounds =
24872487
if (lo eq hi) TypeAlias(lo, 0)
24882488
else unique(new RealTypeBounds(lo, hi))
2489-
def empty(implicit ctx: Context) = real(defn.NothingType, defn.AnyType)
2490-
def upper(hi: Type)(implicit ctx: Context) = real(defn.NothingType, hi)
2491-
def lower(lo: Type)(implicit ctx: Context) = real(lo, defn.AnyType)
2489+
def empty(implicit ctx: Context) = apply(defn.NothingType, defn.AnyType)
2490+
def upper(hi: Type)(implicit ctx: Context) = apply(defn.NothingType, hi)
2491+
def lower(lo: Type)(implicit ctx: Context) = apply(lo, defn.AnyType)
24922492
}
24932493

24942494
object TypeAlias {

0 commit comments

Comments
 (0)