@@ -165,7 +165,7 @@ trait SpaceLogic {
165165 }
166166
167167 /** Is `a` a subspace of `b`? Equivalent to `a - b == Empty`, but faster */
168- def isSubspace (a : Space , b : Space )(using Context ): Boolean = trace(s " ${show(a)} < ${show(b)}" , debug) {
168+ def isSubspace (a : Space , b : Space )(using Context ): Boolean = trace(s " isSubspace( ${show(a)}, ${show(b)}) " , debug) {
169169 def tryDecompose1 (tp : Type ) = canDecompose(tp) && isSubspace(Or (decompose(tp)), b)
170170 def tryDecompose2 (tp : Type ) = canDecompose(tp) && isSubspace(a, Or (decompose(tp)))
171171
@@ -515,15 +515,22 @@ class SpaceEngine(using Context) extends SpaceLogic {
515515 if converted == null then tp else ConstantType (converted)
516516 case _ => tp
517517
518+ /** Adapt types by performing primitive value boxing. #12805 */
519+ def maybeBox (tp1 : Type , tp2 : Type ): Type =
520+ if tp1.classSymbol.isPrimitiveValueClass && ! tp2.classSymbol.isPrimitiveValueClass then
521+ defn.boxedType(tp1).narrow
522+ else tp1
523+
518524 /** Is `tp1` a subtype of `tp2`? */
519525 def isSubType (_tp1 : Type , tp2 : Type ): Boolean = {
520- val tp1 = convertConstantType(_tp1, tp2)
521- debug.println(TypeComparer .explained(_.isSubType(tp1, tp2)))
526+ val tp1 = maybeBox( convertConstantType(_tp1, tp2) , tp2)
527+ // debug.println(TypeComparer.explained(_.isSubType(tp1, tp2)))
522528 val res = if (ctx.explicitNulls) {
523529 tp1 <:< tp2
524530 } else {
525531 (tp1 != constantNullType || tp2 == constantNullType) && tp1 <:< tp2
526532 }
533+ debug.println(i " $tp1 <:< $tp2 = $res" )
527534 res
528535 }
529536
@@ -663,7 +670,6 @@ class SpaceEngine(using Context) extends SpaceLogic {
663670 parts.map(Typ (_, true ))
664671 }
665672
666-
667673 /** Abstract sealed types, or-types, Boolean and Java enums can be decomposed */
668674 def canDecompose (tp : Type ): Boolean =
669675 val res = tp.dealias match
@@ -679,7 +685,7 @@ class SpaceEngine(using Context) extends SpaceLogic {
679685 || cls.isAllOf(JavaEnumTrait )
680686 || tp.isRef(defn.BooleanClass )
681687 || tp.isRef(defn.UnitClass )
682- debug.println(s " decomposable: ${tp.show} = $res" )
688+ // debug.println(s"decomposable: ${tp.show} = $res")
683689 res
684690
685691 /** Show friendly type name with current scope in mind
0 commit comments