Skip to content

Commit f194098

Browse files
committed
Tweak: Make root addition handler take a context
Since root addition handlers are stored in capture sets they should not close over a context, since otherwise every capture set would close over a context. # Conflicts: # tests/pos-with-compiler-cc/dotc/cc/CaptureSet.scala
1 parent 055beab commit f194098

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

compiler/src/dotty/tools/dotc/cc/CaptureSet.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ sealed abstract class CaptureSet extends Showable:
271271
map(Substituters.SubstParamsMap(tl, to))
272272

273273
/** Invoke handler if this set has (or later aquires) the root capability `*` */
274-
def disallowRootCapability(handler: () => Unit)(using Context): this.type =
274+
def disallowRootCapability(handler: () => Context ?=> Unit)(using Context): this.type =
275275
if isUniversal then handler()
276276
this
277277

@@ -378,7 +378,7 @@ object CaptureSet:
378378
def isAlwaysEmpty = false
379379

380380
/** A handler to be invoked if the root reference `*` is added to this set */
381-
var addRootHandler: () => Unit = () => ()
381+
var rootAddedHandler: () => Context ?=> Unit = () => ()
382382

383383
var description: String = ""
384384

@@ -409,7 +409,7 @@ object CaptureSet:
409409
def addNewElems(newElems: Refs, origin: CaptureSet)(using Context, VarState): CompareResult =
410410
if !isConst && recordElemsState() then
411411
elems ++= newElems
412-
if isUniversal then addRootHandler()
412+
if isUniversal then rootAddedHandler()
413413
// assert(id != 2 || elems.size != 2, this)
414414
(CompareResult.OK /: deps) { (r, dep) =>
415415
r.andAlso(dep.tryInclude(newElems, this))
@@ -426,8 +426,8 @@ object CaptureSet:
426426
else
427427
CompareResult.fail(this)
428428

429-
override def disallowRootCapability(handler: () => Unit)(using Context): this.type =
430-
addRootHandler = handler
429+
override def disallowRootCapability(handler: () => Context ?=> Unit)(using Context): this.type =
430+
rootAddedHandler = handler
431431
super.disallowRootCapability(handler)
432432

433433
private var computingApprox = false

0 commit comments

Comments
 (0)