@@ -1193,7 +1193,7 @@ object Types {
1193
1193
else tp.derivedOrType(tp1Widen, defn.NullType )
1194
1194
case tp =>
1195
1195
tp.widenUnionWithoutNull
1196
- }.reporting( i " widenUnion( $this ) = $result " )
1196
+ }
1197
1197
1198
1198
def widenUnionWithoutNull (using Context ): Type =
1199
1199
@@ -1214,19 +1214,28 @@ object Types {
1214
1214
1215
1215
def recombine (tp1 : Type , tp2 : Type ) = harden(TypeComparer .lub(tp1, tp2))
1216
1216
1217
+ inline val asymmetric = false
1218
+
1217
1219
widen match
1218
1220
case tp @ OrType (lhs, rhs) =>
1219
- if tp.isSoft then
1220
- val (lhsCore, lhsExtras) = splitAlts(lhs.widenUnionWithoutNull, Nil )
1221
- val (rhsCore, rhsExtras) = splitAlts(rhs.widenUnionWithoutNull, Nil )
1222
- val core = TypeComparer .lub(lhsCore, rhsCore, canConstrain = true ) match
1221
+ if asymmetric then
1222
+ if tp.isSoft then
1223
+ val (lhsCore, lhsExtras) = splitAlts(lhs.widenUnionWithoutNull, Nil )
1224
+ val (rhsCore, rhsExtras) = splitAlts(rhs.widenUnionWithoutNull, Nil )
1225
+ val core = TypeComparer .lub(lhsCore, rhsCore, canConstrain = true ) match
1226
+ case union : OrType => union.join
1227
+ case res => res
1228
+ rhsExtras.foldLeft(lhsExtras.foldLeft(core)(recombine))(recombine)
1229
+ else
1230
+ val lhs1 = lhs.widenUnionWithoutNull
1231
+ val rhs1 = rhs.widenUnionWithoutNull
1232
+ if (lhs1 eq lhs) && (rhs1 eq rhs) then tp else recombine(lhs1, rhs1)
1233
+ else if tp.isSoft then
1234
+ TypeComparer .lub(lhs.widenUnionWithoutNull, rhs.widenUnionWithoutNull, canConstrain = true ) match
1223
1235
case union : OrType => union.join
1224
1236
case res => res
1225
- rhsExtras.foldLeft(lhsExtras.foldLeft(core)(recombine))(recombine)
1226
1237
else
1227
- val lhs1 = lhs.widenUnionWithoutNull
1228
- val rhs1 = rhs.widenUnionWithoutNull
1229
- if (lhs1 eq lhs) && (rhs1 eq rhs) then tp else recombine(lhs1, rhs1)
1238
+ tp.derivedOrType(lhs.widenUnionWithoutNull, rhs.widenUnionWithoutNull)
1230
1239
case tp @ AndType (tp1, tp2) =>
1231
1240
tp derived_& (tp1.widenUnionWithoutNull, tp2.widenUnionWithoutNull)
1232
1241
case tp : RefinedType =>
0 commit comments