@@ -606,31 +606,15 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
606
606
*/
607
607
def instantiate (tp1 : NamedType , tp2 : Type )(implicit ctx : Context ): Type = {
608
608
// expose abstract type references to their bounds or tvars according to variance
609
- class AbstractTypeMap (maximize : Boolean )(implicit ctx : Context ) extends TypeMap {
610
- def expose (lo : Type , hi : Type ): Type =
611
- if (variance == 0 )
612
- newTypeVar(TypeBounds (lo, hi))
613
- else if (variance == 1 )
614
- if (maximize) hi else lo
615
- else
616
- if (maximize) lo else hi
609
+ class AbstractTypeMap (maximize : Boolean )(implicit ctx : Context ) extends ApproximatingTypeMap {
610
+ variance = if (maximize) 1 else - 1
617
611
618
612
def apply (tp : Type ): Type = tp match {
619
613
case tp : TypeRef if tp.underlying.isInstanceOf [TypeBounds ] =>
620
614
val lo = this (tp.info.loBound)
621
615
val hi = this (tp.info.hiBound)
622
616
// See tests/patmat/gadt.scala tests/patmat/exhausting.scala tests/patmat/t9657.scala
623
- val exposed = expose(lo, hi)
624
- debug.println(s " $tp exposed to =====> $exposed" )
625
- exposed
626
-
627
- case AppliedType (tycon : TypeRef , args) if tycon.underlying.isInstanceOf [TypeBounds ] =>
628
- val args2 = args.map(this )
629
- val lo = this (tycon.info.loBound).applyIfParameterized(args2)
630
- val hi = this (tycon.info.hiBound).applyIfParameterized(args2)
631
- val exposed = expose(lo, hi)
632
- debug.println(s " $tp exposed to =====> $exposed" )
633
- exposed
617
+ range(lo, hi)
634
618
635
619
case _ =>
636
620
mapOver(tp)
0 commit comments