@@ -604,17 +604,19 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
604
604
def childTypeMap (implicit ctx : Context ) = new TypeMap {
605
605
def apply (t : Type ): Type = t.dealias match {
606
606
case tp @ ThisType (tref) if ! tref.symbol.isStaticOwner =>
607
- if (tref.symbol.is(Module )) mapOver (tref)
607
+ if (tref.symbol.is(Module )) this (tref)
608
608
else newTypeVar(TypeBounds .upper(tp.underlying))
609
+
609
610
case tp : TypeRef if tp.underlying.isInstanceOf [TypeBounds ] =>
610
- // Note that the logic for contra- and co-variance is reverse of `typeParamMap `
611
+ // Note that the logic for contra- and co-variance is reverse of `parentTypeMap `
611
612
// This is because we are checking the possibility of `tp1 <:< tp2`, thus we should
612
613
// minimize `tp1` while maximize `tp2`. See tests/patmat/3645b.scala
614
+ val lo = tp.underlying.loBound
615
+ val hi = tp.underlying.hiBound
613
616
val exposed =
614
- if (variance == 0 ) newTypeVar(tp.underlying.bounds)
615
- else if (variance == 1 ) mapOver(tp.underlying.loBound)
616
- else mapOver(tp.underlying.hiBound)
617
-
617
+ if (variance == 0 ) newTypeVar(TypeBounds (this (lo), this (hi)))
618
+ else if (variance == 1 ) this (lo)
619
+ else this (hi)
618
620
debug.println(s " $tp exposed to =====> $exposed" )
619
621
exposed
620
622
case _ =>
@@ -627,10 +629,12 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
627
629
def apply (t : Type ): Type = t.dealias match {
628
630
case tp : TypeRef if tp.underlying.isInstanceOf [TypeBounds ] =>
629
631
// See tests/patmat/gadt.scala tests/patmat/exhausting.scala tests/patmat/t9657.scala
632
+ val lo = tp.underlying.loBound
633
+ val hi = tp.underlying.hiBound
630
634
val exposed =
631
- if (variance == 0 ) newTypeVar(tp.underlying.bounds )
632
- else if (variance == 1 ) mapOver(tp.underlying.hiBound )
633
- else mapOver(tp.underlying.loBound )
635
+ if (variance == 0 ) newTypeVar(TypeBounds ( this (lo), this (hi)) )
636
+ else if (variance == 1 ) this (hi )
637
+ else this (lo )
634
638
635
639
debug.println(s " $tp exposed to =====> $exposed" )
636
640
exposed
0 commit comments