@@ -401,6 +401,7 @@ object TypeOps:
401
401
def avoid (tp : Type , symsToAvoid : => List [Symbol ])(using Context ): Type = {
402
402
val widenMap = new ApproximatingTypeMap {
403
403
@ threadUnsafe lazy val forbidden = symsToAvoid.toSet
404
+ val locals = util.HashSet [Type ]()
404
405
def toAvoid (sym : Symbol ) = ! sym.isStatic && forbidden.contains(sym)
405
406
def partsToAvoid = new NamedPartsAccumulator (tp => toAvoid(tp.symbol))
406
407
@@ -429,19 +430,24 @@ object TypeOps:
429
430
case _ =>
430
431
emptyRange // should happen only in error cases
431
432
}
432
- case tp : ThisType if toAvoid(tp.cls) =>
433
- range(defn. NothingType , apply(classBound(tp.cls.classInfo)))
433
+ case tp : ThisType =>
434
+ tp
434
435
case tp : SkolemType if partsToAvoid(Nil , tp.info).nonEmpty =>
435
436
range(defn.NothingType , apply(tp.info))
436
437
case tp : TypeVar if mapCtx.typerState.constraint.contains(tp) =>
437
438
val lo = TypeComparer .instanceType(
438
439
tp.origin, fromBelow = variance > 0 || variance == 0 && tp.hasLowerBound)(using mapCtx)
439
440
val lo1 = apply(lo)
440
441
if (lo1 ne lo) lo1 else tp
442
+ case tp : LazyRef if locals.contains(tp.ref) =>
443
+ tp
441
444
case tp : LazyRef if isExpandingBounds =>
442
445
if variance == 1 then defn.AnyType
443
446
else if variance == - 1 then defn.NothingType
444
447
else TypeBounds .empty
448
+ case tl : HKTypeLambda =>
449
+ locals ++= tl.paramRefs
450
+ mapOver(tl)
445
451
case _ =>
446
452
mapOver(tp)
447
453
}
0 commit comments