Skip to content

Commit 8a1d0ab

Browse files
committed
Some tweaks after code walkthrough
1 parent 9334f29 commit 8a1d0ab

File tree

1 file changed

+6
-22
lines changed

1 file changed

+6
-22
lines changed

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

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ class CheckCaptures extends Recheck, SymTransformer:
259259
* is that it is sometimes better for type inference to not constrain too early
260260
* with a checkConformsExpr.
261261
*/
262-
private var todoAtPostCheck = new mutable.ListBuffer[() => Unit]
262+
private val todoAtPostCheck = new mutable.ListBuffer[() => Unit]
263263

264264
override def keepType(tree: Tree) =
265265
super.keepType(tree)
@@ -453,8 +453,8 @@ class CheckCaptures extends Recheck, SymTransformer:
453453
val isVisible = c.pathRoot match
454454
case ref: NamedType => isVisibleFromEnv(ref.symbol.owner, env)
455455
case ref: ThisType => isVisibleFromEnv(ref.cls, env)
456-
case ref =>
457-
false
456+
case ref => false
457+
458458
if !isVisible then
459459
if ccConfig.deferredReaches
460460
then avoidLocalCapability(c, env, lastEnv)
@@ -603,22 +603,6 @@ class CheckCaptures extends Recheck, SymTransformer:
603603
case _ => formal
604604
funtpe.derivedLambdaType(paramInfos = paramInfosWithUses)
605605

606-
/** If this is an application of a caps.unsafe method, handle it specially
607-
* otherwise return NoType.
608-
*/
609-
private def recheckUnsafeApply(tree: Apply, pt: Type)(using Context): Type =
610-
val meth = tree.fun.symbol
611-
if meth == defn.Caps_unsafeAssumePure then
612-
val arg :: Nil = tree.args: @unchecked
613-
val argType0 = recheck(arg, pt.capturing(CaptureSet.universal))
614-
val argType =
615-
if argType0.captureSet.isAlwaysEmpty then argType0
616-
else argType0.widen.stripCapturing
617-
capt.println(i"rechecking $arg with $pt: $argType")
618-
super.recheckFinish(argType, tree, pt)
619-
else NoType
620-
end recheckUnsafeApply
621-
622606
/** Recheck applications, with special handling of unsafeAssumePure.
623607
* More work is done in `recheckApplication`, `recheckArg` and `instantiate` below.
624608
*/
@@ -667,7 +651,7 @@ class CheckCaptures extends Recheck, SymTransformer:
667651
* is the capture set of the argument.
668652
* If the function `f` does have an `@use` parameter, then it could in addition
669653
* unbox reach capabilities over its formal parameter. Therefore, the approximation
670-
* would be `Cq \union dcs(Ca)` instead.
654+
* would be `Cq \union dcs(Ta)` instead.
671655
* If the approximation might subcapture the declared result Cr, we pick it for C
672656
* otherwise we pick Cr.
673657
*/
@@ -741,7 +725,7 @@ class CheckCaptures extends Recheck, SymTransformer:
741725
for (getterName, argType) <- mt.paramNames.lazyZip(argTypes) do
742726
val getter = cls.info.member(getterName).suchThat(_.isRefiningParamAccessor).symbol
743727
if !getter.is(Private) && getter.hasTrackedParts then
744-
refined = RefinedType(refined, getterName, argType.unboxed)
728+
refined = RefinedType(refined, getterName, argType.unboxed) // Yichen you might want to check this
745729
allCaptures ++= argType.captureSet
746730
(refined, allCaptures)
747731

@@ -783,7 +767,7 @@ class CheckCaptures extends Recheck, SymTransformer:
783767
end recheckTypeApply
784768

785769
/** Faced with a tree of form `caps.contansImpl[CS, r.type]`, check that `R` is a tracked
786-
* capability and assert that `{r} <:CS`.
770+
* capability and assert that `{r} <: CS`.
787771
*/
788772
def checkContains(tree: TypeApply)(using Context): Unit = tree match
789773
case ContainsImpl(csArg, refArg) =>

0 commit comments

Comments
 (0)