Skip to content

Commit a25ddf5

Browse files
committed
Avoid expanding local paramRef in HKTypeLambda
1 parent 338029a commit a25ddf5

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

compiler/src/dotty/tools/dotc/core/TypeOps.scala

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ object TypeOps:
401401
def avoid(tp: Type, symsToAvoid: => List[Symbol])(using Context): Type = {
402402
val widenMap = new ApproximatingTypeMap {
403403
@threadUnsafe lazy val forbidden = symsToAvoid.toSet
404+
val locals = util.HashSet[Type]()
404405
def toAvoid(sym: Symbol) = !sym.isStatic && forbidden.contains(sym)
405406
def partsToAvoid = new NamedPartsAccumulator(tp => toAvoid(tp.symbol))
406407

@@ -429,19 +430,24 @@ object TypeOps:
429430
case _ =>
430431
emptyRange // should happen only in error cases
431432
}
432-
case tp: ThisType if toAvoid(tp.cls) =>
433-
range(defn.NothingType, apply(classBound(tp.cls.classInfo)))
433+
case tp: ThisType =>
434+
tp
434435
case tp: SkolemType if partsToAvoid(Nil, tp.info).nonEmpty =>
435436
range(defn.NothingType, apply(tp.info))
436437
case tp: TypeVar if mapCtx.typerState.constraint.contains(tp) =>
437438
val lo = TypeComparer.instanceType(
438439
tp.origin, fromBelow = variance > 0 || variance == 0 && tp.hasLowerBound)(using mapCtx)
439440
val lo1 = apply(lo)
440441
if (lo1 ne lo) lo1 else tp
442+
case tp: LazyRef if locals.contains(tp.ref) =>
443+
tp
441444
case tp: LazyRef if isExpandingBounds =>
442445
if variance == 1 then defn.AnyType
443446
else if variance == -1 then defn.NothingType
444447
else TypeBounds.empty
448+
case tl: HKTypeLambda =>
449+
locals ++= tl.paramRefs
450+
mapOver(tl)
445451
case _ =>
446452
mapOver(tp)
447453
}

0 commit comments

Comments
 (0)