@@ -3410,29 +3410,34 @@ class TrackingTypeComparer(initctx: Context) extends TypeComparer(initctx) {
3410
3410
// Actual matching logic
3411
3411
3412
3412
val instances = Array .fill[Type ](spec.captureCount)(NoType )
3413
+ val noInstances = mutable.ListBuffer .empty[(TypeName , TypeBounds )]
3413
3414
3414
3415
def rec (pattern : MatchTypeCasePattern , scrut : Type , variance : Int , scrutIsWidenedAbstract : Boolean ): Boolean =
3415
3416
pattern match
3416
3417
case MatchTypeCasePattern .Capture (num, isWildcard) =>
3418
+ def addNoInstances (bounds : TypeBounds ): TypeBounds =
3419
+ noInstances += spec.origMatchCase.paramNames(num) -> bounds
3420
+ bounds
3421
+
3417
3422
instances(num) = scrut match
3418
3423
case scrut : TypeBounds =>
3419
3424
if isWildcard then
3420
3425
// anything will do, as long as it conforms to the bounds for the subsequent `scrut <:< instantiatedPat` test
3421
- scrut.hi
3426
+ scrut
3422
3427
else if scrutIsWidenedAbstract then
3423
3428
// always keep the TypeBounds so that we can report the correct NoInstances
3424
- scrut
3429
+ addNoInstances( scrut)
3425
3430
else
3426
3431
variance match
3427
3432
case 1 => scrut.hi
3428
3433
case - 1 => scrut.lo
3429
- case 0 => scrut
3434
+ case 0 => addNoInstances( scrut)
3430
3435
case _ =>
3431
3436
if ! isWildcard && scrutIsWidenedAbstract && variance != 0 then
3432
3437
// force a TypeBounds to report the correct NoInstances
3433
3438
// the Nothing and Any bounds are used so that they are not displayed; not for themselves in particular
3434
- if variance > 0 then TypeBounds (defn.NothingType , scrut)
3435
- else TypeBounds (scrut, defn.AnyType )
3439
+ if variance > 0 then addNoInstances( TypeBounds (defn.NothingType , scrut) )
3440
+ else addNoInstances( TypeBounds (scrut, defn.AnyType ) )
3436
3441
else
3437
3442
scrut
3438
3443
! instances(num).isError
@@ -3507,24 +3512,31 @@ class TrackingTypeComparer(initctx: Context) extends TypeComparer(initctx) {
3507
3512
else
3508
3513
MatchResult .Stuck
3509
3514
3515
+ // println(spec.pattern)
3510
3516
if rec(spec.pattern, scrut, variance = 1 , scrutIsWidenedAbstract = false ) then
3511
- if instances.exists(_.isInstanceOf [TypeBounds ]) then
3512
- MatchResult .NoInstance {
3517
+ if noInstances.nonEmpty then
3518
+ // println(1)
3519
+ MatchResult .NoInstance (noInstances.toList)
3520
+ /* {
3513
3521
constrainedCaseLambda.paramNames.zip(instances).collect {
3514
3522
case (name, bounds: TypeBounds) => (name, bounds)
3515
3523
}
3516
- }
3524
+ }*/
3517
3525
else
3518
3526
val defn .MatchCase (instantiatedPat, reduced) =
3519
3527
instantiateParamsSpec(instances, constrainedCaseLambda)(constrainedCaseLambda.resultType): @ unchecked
3528
+ // println(i"$scrut <:< $instantiatedPat")
3520
3529
if scrut <:< instantiatedPat then
3530
+ // println(2)
3521
3531
if disjoint then
3522
3532
MatchResult .ReducedAndDisjoint
3523
3533
else
3524
3534
MatchResult .Reduced (reduced)
3525
3535
else
3536
+ // println(3)
3526
3537
tryDisjoint
3527
3538
else
3539
+ // println(4)
3528
3540
tryDisjoint
3529
3541
end matchSpeccedPatMat
3530
3542
0 commit comments