@@ -98,8 +98,12 @@ object Types extends TypeUtils {
9898// ----- Tests -----------------------------------------------------
9999
100100// // debug only: a unique identifier for a type
101- // val uniqId = { nextId = nextId + 1; nextId }
102- // if uniqId == 19555 then trace.dumpStack()
101+ // val uniqId = {
102+ // nextId = nextId + 1
103+ // if (nextId == 19555)
104+ // println("foo")
105+ // nextId
106+ // }
103107
104108 /** A cache indicating whether the type was still provisional, last time we checked */
105109 @ sharable private var mightBeProvisional = true
@@ -5578,25 +5582,24 @@ object Types extends TypeUtils {
55785582 }
55795583
55805584 def & (that : TypeBounds )(using Context ): TypeBounds =
5581- val lo1 = this .lo.stripLazyRef
5582- val lo2 = that.lo.stripLazyRef
5583- val hi1 = this .hi.stripLazyRef
5584- val hi2 = that.hi.stripLazyRef
5585-
55865585 // This will try to preserve the FromJavaObjects type in upper bounds.
55875586 // For example, (? <: FromJavaObjects | Null) & (? <: Any),
55885587 // we want to get (? <: FromJavaObjects | Null) intead of (? <: Any),
55895588 // because we may check the result <:< (? <: Object | Null) later.
5590- if hi1.containsFromJavaObject && (hi1 frozen_<:< hi2) && (lo2 frozen_<:< lo1) then
5589+ if this .hi.containsFromJavaObject
5590+ && (this .hi frozen_<:< that.hi)
5591+ && (that.lo frozen_<:< this .lo) then
55915592 // FromJavaObject in tp1.hi guarantees tp2.hi <:< tp1.hi
55925593 // prefer tp1 if FromJavaObject is in its hi
55935594 this
5594- else if hi2.containsFromJavaObject && (hi2 frozen_<:< hi1) && (lo1 frozen_<:< lo2) then
5595+ else if that.hi.containsFromJavaObject
5596+ && (that.hi frozen_<:< this .hi)
5597+ && (this .lo frozen_<:< that.lo) then
55955598 // Similarly, prefer tp2 if FromJavaObject is in its hi
55965599 that
5597- else if (lo1 frozen_<:< lo2 ) && (hi2 frozen_<:< hi1 ) then that
5598- else if (lo2 frozen_<:< lo1 ) && (hi1 frozen_<:< hi2 ) then this
5599- else TypeBounds (lo1 | lo2, hi1 & hi2 )
5600+ else if (this .lo frozen_<:< that.lo ) && (that.hi frozen_<:< this .hi ) then that
5601+ else if (that.lo frozen_<:< this .lo ) && (this .hi frozen_<:< that.hi ) then this
5602+ else TypeBounds (this .lo | that.lo, this .hi & that.hi )
56005603
56015604 def | (that : TypeBounds )(using Context ): TypeBounds =
56025605 if ((this .lo frozen_<:< that.lo) && (that.hi frozen_<:< this .hi)) this
@@ -5605,7 +5608,7 @@ object Types extends TypeUtils {
56055608
56065609 override def & (that : Type )(using Context ): Type = that match {
56075610 case that : TypeBounds => this & that
5608- case _ => super .& (that)
5611+ case _ => super .& (that)
56095612 }
56105613
56115614 override def | (that : Type )(using Context ): Type = that match {
0 commit comments