@@ -495,30 +495,31 @@ trait ConstraintHandling[AbstractContext] {
495
495
*
496
496
* @return The pruned type if all `addLess` calls succeed, `NoType` otherwise.
497
497
*/
498
- def prune (bound : Type ): Type = bound match {
499
- case bound : AndType =>
500
- val p1 = prune(bound .tp1)
501
- val p2 = prune(bound .tp2)
502
- if (p1.exists && p2.exists) bound .derivedAndType(p1, p2)
498
+ def prune (bnd : Type ): Type = bnd match {
499
+ case bnd : AndType if ! fromBelow =>
500
+ val p1 = prune(bnd .tp1)
501
+ val p2 = prune(bnd .tp2)
502
+ if (p1.exists && p2.exists) bnd .derivedAndType(p1, p2)
503
503
else NoType
504
- case bound : OrType =>
505
- val p1 = prune(bound .tp1)
506
- val p2 = prune(bound .tp2)
507
- if (p1.exists && p2.exists) bound .derivedOrType(p1, p2)
504
+ case bnd : OrType if fromBelow =>
505
+ val p1 = prune(bnd .tp1)
506
+ val p2 = prune(bnd .tp2)
507
+ if (p1.exists && p2.exists) bnd .derivedOrType(p1, p2)
508
508
else NoType
509
- case bound : TypeVar if constraint contains bound .origin =>
510
- prune(bound .underlying)
511
- case bound : TypeParamRef =>
512
- constraint.entry(bound ) match {
513
- case NoType => pruneLambdaParams(bound )
509
+ case bnd : TypeVar if constraint contains bnd .origin =>
510
+ prune(bnd .underlying)
511
+ case bnd : TypeParamRef if bnd ne param =>
512
+ constraint.entry(bnd ) match {
513
+ case NoType => pruneLambdaParams(bnd )
514
514
case _ : TypeBounds =>
515
- if (! addParamBound(bound)) NoType
515
+ assertFail(i " pruning $param $bound $fromBelow $bnd" )
516
+ if (! addParamBound(bnd)) NoType
516
517
else if (fromBelow) defn.NothingType
517
518
else defn.AnyType
518
519
case inst =>
519
520
prune(inst)
520
521
}
521
- case bound : ExprType =>
522
+ case bnd : ExprType =>
522
523
// ExprTypes are not value types, so type parameters should not
523
524
// be instantiated to ExprTypes. A scenario where such an attempted
524
525
// instantiation can happen is if we unify (=> T) => () with A => ()
@@ -530,7 +531,7 @@ trait ConstraintHandling[AbstractContext] {
530
531
// the resulting types down) and is largely unknown terrain.
531
532
NoType
532
533
case _ =>
533
- pruneLambdaParams(bound )
534
+ pruneLambdaParams(bnd )
534
535
}
535
536
536
537
def kindCompatible (tp1 : Type , tp2 : Type ): Boolean =
0 commit comments