@@ -244,44 +244,36 @@ object TypeOps:
244
244
245
245
def mergeRefinedOrApplied (tp1 : Type , tp2 : Type ): Type = {
246
246
def fail = throw new AssertionError (i " Failure to join alternatives $tp1 and $tp2" )
247
- def fallback = tp2 match
247
+
248
+ tp2 match
248
249
case AndType (tp21, tp22) =>
249
- mergeRefinedOrApplied(tp1, tp21) & mergeRefinedOrApplied(tp1, tp22)
250
+ return mergeRefinedOrApplied(tp1, tp21) & mergeRefinedOrApplied(tp1, tp22)
250
251
case _ =>
251
- fail
252
- tp1 match {
252
+
253
+ if tp1 eq tp2 then tp1
254
+ else tp1 match
253
255
case tp1 @ RefinedType (parent1, name1, rinfo1) =>
254
- tp2 match {
256
+ tp2 match
255
257
case RefinedType (parent2, `name1`, rinfo2) =>
256
258
tp1.derivedRefinedType(
257
259
mergeRefinedOrApplied(parent1, parent2), name1, rinfo1 | rinfo2)
258
- case _ => fallback
259
- }
260
+ case _ => fail
260
261
case tp1 @ AppliedType (tycon1, args1) =>
261
- tp2 match {
262
+ tp2 match
262
263
case AppliedType (tycon2, args2) =>
263
264
tp1.derivedAppliedType(
264
265
mergeRefinedOrApplied(tycon1, tycon2),
265
266
TypeComparer .lubArgs(args1, args2, tycon1.typeParams))
266
- case _ => fallback
267
- }
267
+ case _ => fail
268
268
case tp1 @ TypeRef (pre1, _) =>
269
- tp2 match {
269
+ tp2 match
270
270
case tp2 @ TypeRef (pre2, _) if tp1.name eq tp2.name =>
271
271
tp1.derivedSelect(pre1 | pre2)
272
- case _ => fallback
273
- }
274
- case tp1 : TypeParamRef =>
275
- tp2 match {
276
- case tp2 : TypeParamRef
277
- if (tp1.binder eq tp2.binder) && (tp1.paramNum == tp2.paramNum) =>
278
- tp1
279
- case _ => fallback
280
- }
272
+ case _ => fail
281
273
case AndType (tp11, tp12) =>
282
274
mergeRefinedOrApplied(tp11, tp2) & mergeRefinedOrApplied(tp12, tp2)
275
+ case tp1 : TypeParamRef if tp1 == tp2 => tp1
283
276
case _ => fail
284
- }
285
277
}
286
278
287
279
def approximateOr (tp1 : Type , tp2 : Type ): Type = {
0 commit comments