@@ -325,7 +325,7 @@ class CheckCaptures extends Recheck, SymTransformer:
325325 case t @ CapturingType (parent, refs) =>
326326 for ref <- refs.elems do
327327 ref match
328- case Fresh (hidden) if ! hidden.givenOwner.exists =>
328+ case root. Fresh (hidden) if ! hidden.givenOwner.exists =>
329329 hidden.givenOwner = sym
330330 case _ =>
331331 traverse(parent)
@@ -353,7 +353,7 @@ class CheckCaptures extends Recheck, SymTransformer:
353353 /** If `res` is not CompareResult.OK, report an error */
354354 def checkOK (res : CompareResult , prefix : => String , added : CaptureRef | CaptureSet , pos : SrcPos , provenance : => String = " " )(using Context ): Unit =
355355 if ! res.isOK then
356- inContext(Fresh .printContext(added, res.blocking)):
356+ inContext(root .printContext(added, res.blocking)):
357357 def toAdd : String = CaptureSet .levelErrors.toAdd.mkString
358358 def descr : String =
359359 val d = res.blocking.description
@@ -714,7 +714,7 @@ class CheckCaptures extends Recheck, SymTransformer:
714714 * charge the deep capture set of the actual argument to the environment.
715715 */
716716 protected override def recheckArg (arg : Tree , formal : Type )(using Context ): Type =
717- val freshenedFormal = Fresh .fromCap (formal)
717+ val freshenedFormal = root.capToFresh (formal)
718718 val argType = recheck(arg, freshenedFormal)
719719 .showing(i " recheck arg $arg vs $freshenedFormal" , capt)
720720 if formal.hasAnnotation(defn.UseAnnot ) || formal.hasAnnotation(defn.ConsumeAnnot ) then
@@ -748,7 +748,7 @@ class CheckCaptures extends Recheck, SymTransformer:
748748 */
749749 protected override
750750 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))
752752 val qualCaptures = qualType.captureSet
753753 val argCaptures =
754754 for (argType, formal) <- argTypes.lazyZip(funType.paramInfos) yield
@@ -809,14 +809,14 @@ class CheckCaptures extends Recheck, SymTransformer:
809809 *
810810 * Second half: union of initial capture set and all capture sets of arguments
811811 * 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
814814 */
815815 def addParamArgRefinements (core : Type , initCs : CaptureSet ): (Type , CaptureSet ) =
816816 var refined : Type = core
817817 var allCaptures : CaptureSet =
818818 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
820820 else initCs
821821 for (getterName, argType) <- mt.paramNames.lazyZip(argTypes) do
822822 val getter = cls.info.member(getterName).suchThat(_.isRefiningParamAccessor).symbol
@@ -857,7 +857,7 @@ class CheckCaptures extends Recheck, SymTransformer:
857857 case fun @ Select (qual, nme.apply) => qual.symbol.orElse(fun.symbol)
858858 case fun => fun.symbol
859859 disallowCapInTypeArgs(tree.fun, meth, tree.args)
860- val res = Existential .toCap (super .recheckTypeApply(tree, pt))
860+ val res = root.resultToFresh (super .recheckTypeApply(tree, pt))
861861 includeCallCaptures(tree.symbol, res, tree)
862862 checkContains(tree)
863863 res
@@ -909,8 +909,8 @@ class CheckCaptures extends Recheck, SymTransformer:
909909 // which are less intelligible. An example is the line `a = x` in
910910 // neg-custom-args/captures/vars.scala. That's why this code is conditioned.
911911 // 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)
914914 // We need to open existentials here in order not to get vars mixed up in them
915915 // We do the proper check with existentials when we are finished with the closure block.
916916 capt.println(i " pre-check closure $expr of type $res1 against $pt1" )
@@ -1220,13 +1220,13 @@ class CheckCaptures extends Recheck, SymTransformer:
12201220
12211221 private def existentialSubsumesFailureAddenda (using Context ): Addenda =
12221222 ccState.existentialSubsumesFailure match
1223- case Some ((ex @ Existential . Vble (binder), other)) =>
1223+ case Some ((ex @ root. Result (binder), other)) =>
12241224 new Addenda :
12251225 override def toAdd (using Context ): List [String ] =
1226- val ann = ex.annot. asInstanceOf [ Fresh . Annot ]
1226+ val ann = ex.rootAnnot
12271227 i """
12281228 |
1229- |Note that the existential capture root in ${ann .originalBinder.resType}
1229+ |Note that the existential capture root in ${ex.rootAnnot .originalBinder.resType}
12301230 |cannot subsume the capability $other"""
12311231 :: Nil
12321232 case _ => NothingToAdd
@@ -1279,7 +1279,7 @@ class CheckCaptures extends Recheck, SymTransformer:
12791279 actualBoxed
12801280 else
12811281 capt.println(i " conforms failed for ${tree}: $actual vs $expected" )
1282- inContext(Fresh .printContext(actualBoxed, expected1)):
1282+ inContext(root .printContext(actualBoxed, expected1)):
12831283 err.typeMismatch(tree.withType(actualBoxed), expected1,
12841284 addApproxAddenda(
12851285 addenda
0 commit comments