@@ -1018,8 +1018,11 @@ object Types {
1018
1018
*/
1019
1019
def safe_& (that : Type )(using Context ): Type = (this , that) match {
1020
1020
case (TypeBounds (lo1, hi1), TypeBounds (lo2, hi2)) =>
1021
- TypeBounds (OrType (lo1.stripLazyRef, lo2.stripLazyRef), AndType (hi1.stripLazyRef, hi2.stripLazyRef))
1022
- case _ => this & that
1021
+ TypeBounds (
1022
+ OrType .makeHk(lo1.stripLazyRef, lo2.stripLazyRef),
1023
+ AndType .makeHk(hi1.stripLazyRef, hi2.stripLazyRef))
1024
+ case _ =>
1025
+ this & that
1023
1026
}
1024
1027
1025
1028
/** `this & that`, but handle CyclicReferences by falling back to `safe_&`.
@@ -2934,6 +2937,10 @@ object Types {
2934
2937
tp2
2935
2938
else
2936
2939
if (checkValid) apply(tp1, tp2) else unchecked(tp1, tp2)
2940
+
2941
+ /** Like `make`, but also supports higher-kinded types as argument */
2942
+ def makeHk (tp1 : Type , tp2 : Type )(using Context ): Type =
2943
+ ctx.typeComparer.liftIfHK(tp1, tp2, AndType .make(_, _, checkValid = false ), makeHk, _ | _)
2937
2944
}
2938
2945
2939
2946
abstract case class OrType (tp1 : Type , tp2 : Type ) extends AndOrType {
@@ -3020,6 +3027,10 @@ object Types {
3020
3027
def make (tp1 : Type , tp2 : Type )(using Context ): Type =
3021
3028
if (tp1 eq tp2) tp1
3022
3029
else apply(tp1, tp2)
3030
+
3031
+ /** Like `make`, but also supports higher-kinded types as argument */
3032
+ def makeHk (tp1 : Type , tp2 : Type )(using Context ): Type =
3033
+ ctx.typeComparer.liftIfHK(tp1, tp2, OrType (_, _), makeHk, _ & _)
3023
3034
}
3024
3035
3025
3036
/** An extractor object to pattern match against a nullable union.
0 commit comments