@@ -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,17 +430,22 @@ 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
441
- case tp : LazyRef if isExpandingBounds =>
442
- emptyRange
442
+ case tp : LazyRef =>
443
+ if locals.contains(tp.ref) then tp
444
+ else if isExpandingBounds then emptyRange
445
+ else mapOver(tp)
446
+ case tl : HKTypeLambda =>
447
+ locals ++= tl.paramRefs
448
+ mapOver(tl)
443
449
case _ =>
444
450
mapOver(tp)
445
451
}
0 commit comments