Skip to content

Commit be4a2d4

Browse files
committed
Address review
1 parent 68f6ace commit be4a2d4

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +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]()
404+
@threadUnsafe lazy val localParamRefs = util.HashSet[Type]()
405405
def toAvoid(sym: Symbol) = !sym.isStatic && forbidden.contains(sym)
406406
def partsToAvoid = new NamedPartsAccumulator(tp => toAvoid(tp.symbol))
407407

@@ -431,6 +431,10 @@ object TypeOps:
431431
emptyRange // should happen only in error cases
432432
}
433433
case tp: ThisType =>
434+
// ThisType is only used inside a class.
435+
// Therefore, either they don't appear in the type to be avoided, or
436+
// it must be a class that encloses the block whose type is to be avoided.
437+
assert(!toAvoid(tp.cls))
434438
tp
435439
case tp: SkolemType if partsToAvoid(Nil, tp.info).nonEmpty =>
436440
range(defn.NothingType, apply(tp.info))
@@ -440,11 +444,11 @@ object TypeOps:
440444
val lo1 = apply(lo)
441445
if (lo1 ne lo) lo1 else tp
442446
case tp: LazyRef =>
443-
if locals.contains(tp.ref) then tp
447+
if localParamRefs.contains(tp.ref) then tp
444448
else if isExpandingBounds then emptyRange
445449
else mapOver(tp)
446450
case tl: HKTypeLambda =>
447-
locals ++= tl.paramRefs
451+
localParamRefs ++= tl.paramRefs
448452
mapOver(tl)
449453
case _ =>
450454
mapOver(tp)

0 commit comments

Comments
 (0)