@@ -2860,7 +2860,7 @@ object TrackingTypeComparer:
28602860 case Reduced (tp : Type )
28612861 case Disjoint
28622862 case Stuck
2863- case NoInstance (param : Name , bounds : TypeBounds )
2863+ case NoInstance (fails : List [( Name , TypeBounds )] )
28642864
28652865class TrackingTypeComparer (initctx : Context ) extends TypeComparer (initctx) {
28662866 import TrackingTypeComparer .*
@@ -2906,25 +2906,25 @@ class TrackingTypeComparer(initctx: Context) extends TypeComparer(initctx) {
29062906 def paramInstances (canApprox : Boolean ) = new TypeAccumulator [Array [Type ]]:
29072907 def apply (insts : Array [Type ], t : Type ) = t match
29082908 case param @ TypeParamRef (b, n) if b eq caseLambda =>
2909- insts(n) = {
2909+ insts(n) =
29102910 if canApprox then
2911- approximation(param, fromBelow = variance >= 0 )
2911+ approximation(param, fromBelow = variance >= 0 ).simplified
29122912 else constraint.entry(param) match
29132913 case entry : TypeBounds =>
29142914 val lo = fullLowerBound(param)
29152915 val hi = fullUpperBound(param)
2916- if isSubType(hi, lo) then lo else TypeBounds (lo, hi)
2916+ if isSubType(hi, lo) then lo.simplified else Range (lo, hi)
29172917 case inst =>
29182918 assert(inst.exists, i " param = $param\n constraint = $constraint" )
2919- inst
2920- }.simplified
2919+ inst.simplified
29212920 insts
29222921 case _ =>
29232922 foldOver(insts, t)
29242923
2925- def instantiateParams (inst : Array [Type ]) = new TypeMap {
2924+ def instantiateParams (insts : Array [Type ]) = new ApproximatingTypeMap {
2925+ variance = 0
29262926 def apply (t : Type ) = t match {
2927- case t @ TypeParamRef (b, n) if b `eq` caseLambda => inst (n)
2927+ case t @ TypeParamRef (b, n) if b `eq` caseLambda => insts (n)
29282928 case t : LazyRef => apply(t.ref)
29292929 case _ => mapOver(t)
29302930 }
@@ -2957,11 +2957,15 @@ class TrackingTypeComparer(initctx: Context) extends TypeComparer(initctx) {
29572957 caseLambda match
29582958 case caseLambda : HKTypeLambda =>
29592959 val instances = paramInstances(canApprox)(new Array (caseLambda.paramNames.length), pat)
2960- instances.indices.find(instances(_).isInstanceOf [TypeBounds ]) match
2961- case Some (i) if ! canApprox =>
2962- MatchResult .NoInstance (caseLambda.paramNames(i), instances(i).bounds)
2963- case _ =>
2964- MatchResult .Reduced (instantiateParams(instances)(body).simplified)
2960+ instantiateParams(instances)(body) match
2961+ case Range (lo, hi) =>
2962+ MatchResult .NoInstance {
2963+ caseLambda.paramNames.zip(instances).collect {
2964+ case (name, Range (lo, hi)) => (name, TypeBounds (lo, hi))
2965+ }
2966+ }
2967+ case redux =>
2968+ MatchResult .Reduced (redux.simplified)
29652969 case _ =>
29662970 MatchResult .Reduced (body)
29672971
@@ -2985,8 +2989,8 @@ class TrackingTypeComparer(initctx: Context) extends TypeComparer(initctx) {
29852989 case MatchResult .Stuck =>
29862990 MatchTypeTrace .stuck(scrut, cas, remaining1)
29872991 NoType
2988- case MatchResult .NoInstance (pname, bounds ) =>
2989- MatchTypeTrace .noInstance(scrut, cas, pname, bounds )
2992+ case MatchResult .NoInstance (fails ) =>
2993+ MatchTypeTrace .noInstance(scrut, cas, fails )
29902994 NoType
29912995 case MatchResult .Reduced (tp) =>
29922996 tp
0 commit comments