@@ -325,7 +325,7 @@ class CheckCaptures extends Recheck, SymTransformer:
325
325
case t @ CapturingType (parent, refs) =>
326
326
for ref <- refs.elems do
327
327
ref match
328
- case Fresh (hidden) if ! hidden.givenOwner.exists =>
328
+ case root. Fresh (hidden) if ! hidden.givenOwner.exists =>
329
329
hidden.givenOwner = sym
330
330
case _ =>
331
331
traverse(parent)
@@ -353,7 +353,7 @@ class CheckCaptures extends Recheck, SymTransformer:
353
353
/** If `res` is not CompareResult.OK, report an error */
354
354
def checkOK (res : CompareResult , prefix : => String , added : CaptureRef | CaptureSet , pos : SrcPos , provenance : => String = " " )(using Context ): Unit =
355
355
if ! res.isOK then
356
- inContext(Fresh .printContext(added, res.blocking)):
356
+ inContext(root .printContext(added, res.blocking)):
357
357
def toAdd : String = CaptureSet .levelErrors.toAdd.mkString
358
358
def descr : String =
359
359
val d = res.blocking.description
@@ -714,7 +714,7 @@ class CheckCaptures extends Recheck, SymTransformer:
714
714
* charge the deep capture set of the actual argument to the environment.
715
715
*/
716
716
protected override def recheckArg (arg : Tree , formal : Type )(using Context ): Type =
717
- val freshenedFormal = Fresh .fromCap (formal)
717
+ val freshenedFormal = root.capToFresh (formal)
718
718
val argType = recheck(arg, freshenedFormal)
719
719
.showing(i " recheck arg $arg vs $freshenedFormal" , capt)
720
720
if formal.hasAnnotation(defn.UseAnnot ) || formal.hasAnnotation(defn.ConsumeAnnot ) then
@@ -748,7 +748,7 @@ class CheckCaptures extends Recheck, SymTransformer:
748
748
*/
749
749
protected override
750
750
def recheckApplication (tree : Apply , qualType : Type , funType : MethodType , argTypes : List [Type ])(using Context ): Type =
751
- val appType = Existential .toCap (super .recheckApplication(tree, qualType, funType, argTypes))
751
+ val appType = root.resultToFresh (super .recheckApplication(tree, qualType, funType, argTypes))
752
752
val qualCaptures = qualType.captureSet
753
753
val argCaptures =
754
754
for (argType, formal) <- argTypes.lazyZip(funType.paramInfos) yield
@@ -809,14 +809,14 @@ class CheckCaptures extends Recheck, SymTransformer:
809
809
*
810
810
* Second half: union of initial capture set and all capture sets of arguments
811
811
* to tracked parameters. The initial capture set `initCs` is augmented with
812
- * - Fresh(...) if `core` extends Mutable
813
- * - Fresh(...).rd if `core` extends Capability
812
+ * - root. Fresh(...) if `core` extends Mutable
813
+ * - root. Fresh(...).rd if `core` extends Capability
814
814
*/
815
815
def addParamArgRefinements (core : Type , initCs : CaptureSet ): (Type , CaptureSet ) =
816
816
var refined : Type = core
817
817
var allCaptures : CaptureSet =
818
818
if core.derivesFromMutable then initCs ++ CaptureSet .fresh()
819
- else if core.derivesFromCapability then initCs ++ Fresh .withOwner(core.classSymbol).readOnly.singletonCaptureSet
819
+ else if core.derivesFromCapability then initCs ++ root. Fresh .withOwner(core.classSymbol).readOnly.singletonCaptureSet
820
820
else initCs
821
821
for (getterName, argType) <- mt.paramNames.lazyZip(argTypes) do
822
822
val getter = cls.info.member(getterName).suchThat(_.isRefiningParamAccessor).symbol
@@ -857,7 +857,7 @@ class CheckCaptures extends Recheck, SymTransformer:
857
857
case fun @ Select (qual, nme.apply) => qual.symbol.orElse(fun.symbol)
858
858
case fun => fun.symbol
859
859
disallowCapInTypeArgs(tree.fun, meth, tree.args)
860
- val res = Existential .toCap (super .recheckTypeApply(tree, pt))
860
+ val res = root.resultToFresh (super .recheckTypeApply(tree, pt))
861
861
includeCallCaptures(tree.symbol, res, tree)
862
862
checkContains(tree)
863
863
res
@@ -909,8 +909,8 @@ class CheckCaptures extends Recheck, SymTransformer:
909
909
// which are less intelligible. An example is the line `a = x` in
910
910
// neg-custom-args/captures/vars.scala. That's why this code is conditioned.
911
911
// to apply only to closures that are not eta expansions.
912
- val res1 = Existential .toCap (res) // TODO: why deep = true?
913
- val pt1 = Existential .toCap (pt)
912
+ val res1 = root.resultToFresh (res) // TODO: why deep = true?
913
+ val pt1 = root.resultToFresh (pt)
914
914
// We need to open existentials here in order not to get vars mixed up in them
915
915
// We do the proper check with existentials when we are finished with the closure block.
916
916
capt.println(i " pre-check closure $expr of type $res1 against $pt1" )
@@ -1220,13 +1220,13 @@ class CheckCaptures extends Recheck, SymTransformer:
1220
1220
1221
1221
private def existentialSubsumesFailureAddenda (using Context ): Addenda =
1222
1222
ccState.existentialSubsumesFailure match
1223
- case Some ((ex @ Existential . Vble (binder), other)) =>
1223
+ case Some ((ex @ root. Result (binder), other)) =>
1224
1224
new Addenda :
1225
1225
override def toAdd (using Context ): List [String ] =
1226
- val ann = ex.annot. asInstanceOf [ Fresh . Annot ]
1226
+ val ann = ex.rootAnnot
1227
1227
i """
1228
1228
|
1229
- |Note that the existential capture root in ${ann .originalBinder.resType}
1229
+ |Note that the existential capture root in ${ex.rootAnnot .originalBinder.resType}
1230
1230
|cannot subsume the capability $other"""
1231
1231
:: Nil
1232
1232
case _ => NothingToAdd
@@ -1279,7 +1279,7 @@ class CheckCaptures extends Recheck, SymTransformer:
1279
1279
actualBoxed
1280
1280
else
1281
1281
capt.println(i " conforms failed for ${tree}: $actual vs $expected" )
1282
- inContext(Fresh .printContext(actualBoxed, expected1)):
1282
+ inContext(root .printContext(actualBoxed, expected1)):
1283
1283
err.typeMismatch(tree.withType(actualBoxed), expected1,
1284
1284
addApproxAddenda(
1285
1285
addenda
0 commit comments