@@ -289,6 +289,23 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
289
289
}
290
290
}
291
291
292
+ def realiasConstraint (param : Type , alias : NamedType , dealiased : Type ) =
293
+ if alias.symbol.isStatic then
294
+ param.stripTypeVar match
295
+ case param : TypeParamRef =>
296
+ constraint.entry(param) match
297
+ case TypeBounds (lo, hi) =>
298
+ val aliasLo = (alias ne lo) && (dealiased eq lo)
299
+ val aliasHi = (alias ne hi) && (dealiased eq hi)
300
+ if aliasLo || aliasHi then
301
+ constraint = constraint.updateEntry(param, TypeBounds (
302
+ if aliasLo then alias else lo,
303
+ if aliasHi then alias else hi))
304
+ case tp =>
305
+ if (alias ne tp) && (dealiased eq tp) then
306
+ constraint = constraint.updateEntry(param, alias)
307
+ case _ =>
308
+
292
309
def firstTry : Boolean = tp2 match {
293
310
case tp2 : NamedType =>
294
311
def compareNamed (tp1 : Type , tp2 : NamedType ): Boolean =
@@ -297,14 +314,18 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
297
314
val info2 = tp2.info
298
315
info2 match
299
316
case info2 : TypeAlias =>
300
- if recur(tp1, info2.alias) then return true
317
+ val res = recur(tp1, info2.alias)
318
+ realiasConstraint(tp1, tp2, info2.alias)
319
+ if res then return true
301
320
if tp2.asInstanceOf [TypeRef ].canDropAlias then return false
302
321
case _ =>
303
322
tp1 match
304
323
case tp1 : NamedType =>
305
324
tp1.info match {
306
325
case info1 : TypeAlias =>
307
- if recur(info1.alias, tp2) then return true
326
+ val res = recur(info1.alias, tp2)
327
+ realiasConstraint(tp2, tp1, info1.alias)
328
+ if res then return true
308
329
if tp1.asInstanceOf [TypeRef ].canDropAlias then return false
309
330
case _ =>
310
331
}
@@ -413,26 +434,10 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
413
434
case tp1 : NamedType =>
414
435
tp1.info match {
415
436
case info1 : TypeAlias =>
416
- def realiasConstraint () = tp2 match {
417
- case tp2 : TypeParamRef =>
418
- constraint.entry(tp2) match {
419
- case TypeBounds (lo, hi) =>
420
- val aliasLo = (tp1 ne lo) && (info1.alias eq lo)
421
- val aliasHi = (tp1 ne hi) && (info1.alias eq hi)
422
- if aliasLo || aliasHi then
423
- constraint = constraint.updateEntry(tp2, TypeBounds (
424
- if aliasLo then tp1 else lo,
425
- if aliasHi then tp1 else hi))
426
- case tp =>
427
- if (tp1 ne tp) && (info1.alias eq tp) then
428
- constraint = constraint.updateEntry(tp2, tp1)
429
- }
430
- case _ =>
431
- }
432
437
val res = recur(info1.alias, tp2)
433
- if ( tp1.symbol.isStatic) realiasConstraint( )
434
- if ( res) return true
435
- if ( tp1.prefix.isStable) return tryLiftedToThis1
438
+ realiasConstraint(tp2, tp1, info1.alias )
439
+ if res then return true
440
+ if tp1.prefix.isStable then return tryLiftedToThis1
436
441
case _ =>
437
442
if (tp1 eq NothingType ) || isBottom(tp1) then return true
438
443
}
0 commit comments