Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c118823

Browse files
committedMay 1, 2023
Change root capability to cap
1 parent d9750dd commit c118823

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+157
-158
lines changed
 

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ sealed abstract class CaptureSet extends Showable:
7070
assert(!isConst)
7171
asInstanceOf[Var]
7272

73-
/** Does this capture set contain the root reference `*` as element? */
73+
/** Does this capture set contain the root reference `cap` as element? */
7474
final def isUniversal(using Context) =
7575
elems.exists {
7676
case ref: TermRef => ref.symbol == defn.captureRoot
@@ -133,7 +133,7 @@ sealed abstract class CaptureSet extends Showable:
133133
* for `x` in a state where we assume all supersets of `x` have just the elements
134134
* known at this point. On the other hand if x's capture set has no known elements,
135135
* a set `cs` might account for `x` only if it subsumes `x` or it contains the
136-
* root capability `*`.
136+
* root capability `cap`.
137137
*/
138138
def mightAccountFor(x: CaptureRef)(using Context): Boolean =
139139
reporting.trace(i"$this mightAccountFor $x, ${x.captureSetOfInfo}?", show = true) {
@@ -270,7 +270,7 @@ sealed abstract class CaptureSet extends Showable:
270270
def substParams(tl: BindingType, to: List[Type])(using Context) =
271271
map(Substituters.SubstParamsMap(tl, to))
272272

273-
/** Invoke handler if this set has (or later aquires) the root capability `*` */
273+
/** Invoke handler if this set has (or later aquires) the root capability `cap` */
274274
def disallowRootCapability(handler: () => Context ?=> Unit)(using Context): this.type =
275275
if isUniversal then handler()
276276
this
@@ -372,7 +372,7 @@ object CaptureSet:
372372
def isConst = isSolved
373373
def isAlwaysEmpty = false
374374

375-
/** A handler to be invoked if the root reference `*` is added to this set */
375+
/** A handler to be invoked if the root reference `cap` is added to this set */
376376
var rootAddedHandler: () => Context ?=> Unit = () => ()
377377

378378
var description: String = ""

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ class CheckCaptures extends Recheck, SymTransformer:
433433
case defn.FunctionOf(ptformals, _, _)
434434
if ptformals.nonEmpty && ptformals.forall(_.captureSet.isAlwaysEmpty) =>
435435
// Redo setup of the anonymous function so that formal parameters don't
436-
// get capture sets. This is important to avoid false widenings to `*`
436+
// get capture sets. This is important to avoid false widenings to `cap`
437437
// when taking the base type of the actual closures's dependent function
438438
// type so that it conforms to the expected non-dependent function type.
439439
// See withLogFile.scala for a test case.
@@ -582,7 +582,7 @@ class CheckCaptures extends Recheck, SymTransformer:
582582
refs.disallowRootCapability { () =>
583583
val kind = if tree.isInstanceOf[ValDef] then "mutable variable" else "expression"
584584
report.error(
585-
em"""The $kind's type $wtp is not allowed to capture the root capability `*`.
585+
em"""The $kind's type $wtp is not allowed to capture the root capability `cap`.
586586
|This usually means that a capability persists longer than its allowed lifetime.""",
587587
tree.srcPos)
588588
}
@@ -768,9 +768,9 @@ class CheckCaptures extends Recheck, SymTransformer:
768768
styp1.capturing(if alwaysConst then CaptureSet(cs1.elems) else cs1).forceBoxStatus(resultBoxed)
769769

770770
if needsAdaptation then
771-
val criticalSet = // the set which is not allowed to have `*`
772-
if covariant then cs1 // can't box with `*`
773-
else expected.captureSet // can't unbox with `*`
771+
val criticalSet = // the set which is not allowed to have `cap`
772+
if covariant then cs1 // can't box with `cap`
773+
else expected.captureSet // can't unbox with `cap`
774774
if criticalSet.isUniversal && expected.isValueType then
775775
// We can't box/unbox the universal capability. Leave `actual` as it is
776776
// so we get an error in checkConforms. This tends to give better error
@@ -779,11 +779,11 @@ class CheckCaptures extends Recheck, SymTransformer:
779779
println(i"cannot box/unbox $actual vs $expected")
780780
actual
781781
else
782-
// Disallow future addition of `*` to `criticalSet`.
782+
// Disallow future addition of `cap` to `criticalSet`.
783783
criticalSet.disallowRootCapability { () =>
784784
report.error(
785785
em"""$actual cannot be box-converted to $expected
786-
|since one of their capture sets contains the root capability `*`""",
786+
|since one of their capture sets contains the root capability `cap`""",
787787
pos)
788788
}
789789
if !insertBox then // unboxing
@@ -922,8 +922,8 @@ class CheckCaptures extends Recheck, SymTransformer:
922922
* usingLogFile[box ?1 () -> Unit] { (f: {*} File) => () => { f.write(0) } }
923923
*
924924
* We may propagate `f` into ?1, making ?1 ill-formed.
925-
* This also causes soundness issues, since `f` in ?1 should be widened to `*`,
926-
* giving rise to an error that `*` cannot be included in a boxed capture set.
925+
* This also causes soundness issues, since `f` in ?1 should be widened to `cap`,
926+
* giving rise to an error that `cap` cannot be included in a boxed capture set.
927927
*
928928
* To solve this, we still allow ?1 to capture parameter refs like `f`, but
929929
* compensate this by pushing the widened capture set of `f` into ?1.

0 commit comments

Comments
 (0)
Please sign in to comment.