@@ -605,32 +605,16 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
605605 *
606606 */
607607 def instantiate (tp1 : NamedType , tp2 : Type )(implicit ctx : Context ): Type = {
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
608+ // expose type param references to their bounds according to variance
609+ class AbstractTypeMap (maximize : Boolean )(implicit ctx : Context ) extends ApproximatingTypeMap {
610+ variance = if (maximize) 1 else - 1
617611
618612 def apply (tp : Type ): Type = tp match {
619613 case tp : TypeRef if tp.underlying.isInstanceOf [TypeBounds ] =>
620614 val lo = this (tp.info.loBound)
621615 val hi = this (tp.info.hiBound)
622616 // 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)
634618
635619 case _ =>
636620 mapOver(tp)
0 commit comments