@@ -585,17 +585,19 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
585
585
def childTypeMap (implicit ctx : Context ) = new TypeMap {
586
586
def apply (t : Type ): Type = t.dealias match {
587
587
case tp @ ThisType (tref) if ! tref.symbol.isStaticOwner =>
588
- if (tref.symbol.is(Module )) mapOver (tref)
588
+ if (tref.symbol.is(Module )) this (tref)
589
589
else newTypeVar(TypeBounds .upper(tp.underlying))
590
+
590
591
case tp : TypeRef if tp.underlying.isInstanceOf [TypeBounds ] =>
591
- // Note that the logic for contra- and co-variance is reverse of `typeParamMap `
592
+ // Note that the logic for contra- and co-variance is reverse of `parentTypeMap `
592
593
// This is because we are checking the possibility of `tp1 <:< tp2`, thus we should
593
594
// minimize `tp1` while maximize `tp2`. See tests/patmat/3645b.scala
595
+ val lo = tp.underlying.loBound
596
+ val hi = tp.underlying.hiBound
594
597
val exposed =
595
- if (variance == 0 ) newTypeVar(tp.underlying.bounds)
596
- else if (variance == 1 ) mapOver(tp.underlying.loBound)
597
- else mapOver(tp.underlying.hiBound)
598
-
598
+ if (variance == 0 ) newTypeVar(TypeBounds (this (lo), this (hi)))
599
+ else if (variance == 1 ) this (lo)
600
+ else this (hi)
599
601
debug.println(s " $tp exposed to =====> $exposed" )
600
602
exposed
601
603
case _ =>
@@ -608,10 +610,12 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
608
610
def apply (t : Type ): Type = t.dealias match {
609
611
case tp : TypeRef if tp.underlying.isInstanceOf [TypeBounds ] =>
610
612
// See tests/patmat/gadt.scala tests/patmat/exhausting.scala tests/patmat/t9657.scala
613
+ val lo = tp.underlying.loBound
614
+ val hi = tp.underlying.hiBound
611
615
val exposed =
612
- if (variance == 0 ) newTypeVar(tp.underlying.bounds )
613
- else if (variance == 1 ) mapOver(tp.underlying.hiBound )
614
- else mapOver(tp.underlying.loBound )
616
+ if (variance == 0 ) newTypeVar(TypeBounds ( this (lo), this (hi)) )
617
+ else if (variance == 1 ) this (hi )
618
+ else this (lo )
615
619
616
620
debug.println(s " $tp exposed to =====> $exposed" )
617
621
exposed
0 commit comments