@@ -2564,18 +2564,15 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
2564
2564
case _ =>
2565
2565
tp
2566
2566
2567
- private def andTypeGen (tp1orig : Type , tp2orig : Type , op : (Type , Type ) => Type ,
2568
- original : (Type , Type ) => Type = _ & _, isErased : Boolean = ctx.erasedTypes): Type = trace(s " andTypeGen( ${tp1orig.show}, ${tp2orig.show}) " , subtyping, show = true ) {
2569
- val tp1 = tp1orig.stripFlexible
2570
- val tp2 = tp2orig.stripFlexible
2567
+ private def andTypeGen (tp1 : Type , tp2 : Type , op : (Type , Type ) => Type ,
2568
+ original : (Type , Type ) => Type = _ & _, isErased : Boolean = ctx.erasedTypes): Type = trace(s " andTypeGen( ${tp1.show}, ${tp2.show}) " , subtyping, show = true ) {
2571
2569
val t1 = distributeAnd(tp1, tp2)
2572
- val ret =
2573
- if t1.exists then t1
2574
- else
2575
- val t2 = distributeAnd(tp2, tp1)
2576
- if t2.exists then t2
2577
- else if isErased then erasedGlb(tp1, tp2)
2578
- else liftIfHK(tp1, tp2, op, original, _ | _)
2570
+ if (t1.exists) t1
2571
+ else {
2572
+ val t2 = distributeAnd(tp2, tp1)
2573
+ if (t2.exists) t2
2574
+ else if (isErased) erasedGlb(tp1, tp2)
2575
+ else liftIfHK(tp1, tp2, op, original, _ | _)
2579
2576
// The ` | ` on variances is needed since variances are associated with bounds
2580
2577
// not lambdas. Example:
2581
2578
//
@@ -2585,9 +2582,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
2585
2582
//
2586
2583
// Here, `F` is treated as bivariant in `O`. That is, only bivariant implementation
2587
2584
// of `F` are allowed. See neg/hk-variance2s.scala test.
2588
-
2589
- if tp1orig.isInstanceOf [FlexibleType ] && tp2orig.isInstanceOf [FlexibleType ]
2590
- then FlexibleType (ret) else ret
2585
+ }
2591
2586
}
2592
2587
2593
2588
/** Form a normalized conjunction of two types.
0 commit comments