Skip to content

Commit 7c4a9ec

Browse files
committed
TempClassInfo#addSuspension: do not capture Context
This capture did not cause any problem since we always called TempClassInfo#finalize with the same Context than we captured in `addSuspension`, but it's better to be explicit about these things.
1 parent 360406d commit 7c4a9ec

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,12 +401,12 @@ trait TypeOps { this: Context => // TODO: Make standalone object.
401401
def forwardRefs(from: Symbol, to: Type, prefs: List[TypeRef]) = to match {
402402
case to @ TypeBounds(lo1, hi1) if lo1 eq hi1 =>
403403
for (pref <- prefs) {
404-
def forward(): Unit =
404+
def forward()(implicit ctx: Context): Unit =
405405
for (argSym <- pref.decls)
406406
if (argSym is BaseTypeArg)
407407
forwardRef(argSym, from, to, cls, decls)
408408
pref.info match {
409-
case info: TempClassInfo => info.addSuspension(forward)
409+
case info: TempClassInfo => info.addSuspension(implicit ctx => forward())
410410
case _ => forward()
411411
}
412412
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3089,14 +3089,14 @@ object Types {
30893089
* be no longer temporary. These actions will be performed once `cls` gets a real
30903090
* ClassInfo.
30913091
*/
3092-
private var suspensions: List[() => Unit] = Nil
3092+
private var suspensions: List[Context => Unit] = Nil
30933093

3094-
def addSuspension(suspension: () => Unit): Unit = suspensions ::= suspension
3094+
def addSuspension(suspension: Context => Unit): Unit = suspensions ::= suspension
30953095

30963096
/** Install classinfo with known parents in `denot` and resume all suspensions */
30973097
def finalize(denot: SymDenotation, parents: List[TypeRef])(implicit ctx: Context) = {
30983098
denot.info = derivedClassInfo(classParents = parents)
3099-
suspensions.foreach(_())
3099+
suspensions.foreach(_(ctx))
31003100
}
31013101
}
31023102

0 commit comments

Comments
 (0)