Skip to content

Commit fd1f3e7

Browse files
committed
Revert "Address review comments"
This reverts commit 071bf19.
1 parent d843f70 commit fd1f3e7

File tree

6 files changed

+32
-28
lines changed

6 files changed

+32
-28
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ extension (tp: Type)
508508
case _ =>
509509
ReadOnlyCapability(tp)
510510

511-
/** If `x` is a capture ref, replace all no-flip covariant occurrences of `cap`
511+
/** If `x` is a capture ref, replacxe all no-flip covariant occurrences of `cap`
512512
* in type `tp` with `x*`.
513513
*/
514514
def withReachCaptures(ref: Type)(using Context): Type =
@@ -758,7 +758,7 @@ object MaybeCapability extends AnnotatedCapability(defn.MaybeCapabilityAnnot):
758758
protected def unwrappable(using Context) = Set()
759759

760760
/** An extractor for `ref @readOnlyCapability`, which is used to express
761-
* the read-only capability `ref.rd` as a type.
761+
* the rad-only capability `ref.rd` as a type.
762762
*/
763763
object ReadOnlyCapability extends AnnotatedCapability(defn.ReadOnlyCapabilityAnnot):
764764
protected def unwrappable(using Context) = Set(defn.MaybeCapabilityAnnot)

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,13 @@ trait CaptureRef extends TypeProxy, ValueType:
116116
case _ => false
117117

118118
/** An exclusive capability is a capability that derives
119-
* indirectly from a maximal capability without going through
119+
* indirectly from a maximal capability without goinh through
120120
* a read-only capability first.
121121
*/
122122
final def isExclusive(using Context): Boolean =
123123
!isReadOnly && (isMaxCapability || captureSetOfInfo.isExclusive)
124124

125-
// With the support of paths, we don't need to normalize the `TermRef`s anymore.
125+
// With the support of pathes, we don't need to normalize the `TermRef`s anymore.
126126
// /** Normalize reference so that it can be compared with `eq` for equality */
127127
// final def normalizedRef(using Context): CaptureRef = this match
128128
// case tp @ AnnotatedType(parent: CaptureRef, annot) if tp.isTrackableRef =>
@@ -242,7 +242,7 @@ trait CaptureRef extends TypeProxy, ValueType:
242242
case _ => false
243243
end subsumes
244244

245-
/** This is a maximal capability that subsumes `y` in given context and VarState.
245+
/** This is a maximal capabaility that subsumes `y` in given context and VarState.
246246
* @param canAddHidden If true we allow maximal capabilities to subsume all other capabilities.
247247
* We add those capabilities to the hidden set if this is Fresh.Cap
248248
* If false we only accept `y` elements that are already in the

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

+14-10
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,11 @@ sealed abstract class CaptureSet extends Showable:
227227
elems.forall(that.mightAccountFor)
228228
&& !that.elems.forall(this.mightAccountFor)
229229

230-
/** The subcapturing test, taking an explicit VarState. */
230+
/** The subcapturing test.
231+
* @param frozen if true, no new variables or dependent sets are allowed to
232+
* be added when making this test. An attempt to add either
233+
* will result in failure.
234+
*/
231235
final def subCaptures(that: CaptureSet, vs: VarState)(using Context): CompareResult =
232236
subCaptures(that)(using ctx, vs)
233237

@@ -388,7 +392,7 @@ sealed abstract class CaptureSet extends Showable:
388392
override def toText(printer: Printer): Text =
389393
printer.toTextCaptureSet(this) ~~ description
390394

391-
/** Apply function `f` to the elements. Typically used for printing.
395+
/** Apply function `f` to the elements. Typcially used for printing.
392396
* Overridden in HiddenSet so that we don't run into infinite recursions
393397
*/
394398
def processElems[T](f: Refs => T): T = f(elems)
@@ -403,10 +407,10 @@ object CaptureSet:
403407
/** If set to `true`, capture stack traces that tell us where sets are created */
404408
private final val debugSets = false
405409

406-
val emptyRefs: Refs = SimpleIdentitySet.empty
410+
val emptySet = SimpleIdentitySet.empty
407411

408412
/** The empty capture set `{}` */
409-
val empty: CaptureSet.Const = Const(emptyRefs)
413+
val empty: CaptureSet.Const = Const(emptySet)
410414

411415
/** The universal capture set `{cap}` */
412416
def universal(using Context): CaptureSet =
@@ -462,7 +466,7 @@ object CaptureSet:
462466
* nulls, this provides more lenient checking against compilation units that
463467
* were not yet compiled with capture checking on.
464468
*/
465-
object Fluid extends Const(emptyRefs):
469+
object Fluid extends Const(emptySet):
466470
override def isAlwaysEmpty = false
467471
override def addThisElem(elem: CaptureRef)(using Context, VarState) = CompareResult.OK
468472
override def accountsFor(x: CaptureRef)(using Context, VarState): Boolean = true
@@ -471,7 +475,7 @@ object CaptureSet:
471475
end Fluid
472476

473477
/** The subclass of captureset variables with given initial elements */
474-
class Var(override val owner: Symbol = NoSymbol, initialElems: Refs = emptyRefs, val level: Level = undefinedLevel, underBox: Boolean = false)(using @constructorOnly ictx: Context) extends CaptureSet:
478+
class Var(override val owner: Symbol = NoSymbol, initialElems: Refs = emptySet, val level: Level = undefinedLevel, underBox: Boolean = false)(using @constructorOnly ictx: Context) extends CaptureSet:
475479

476480
/** A unique identification number for diagnostics */
477481
val id =
@@ -489,7 +493,7 @@ object CaptureSet:
489493
/** The sets currently known to be dependent sets (i.e. new additions to this set
490494
* are propagated to these dependent sets.)
491495
*/
492-
var deps: Deps = SimpleIdentitySet.empty
496+
var deps: Deps = emptySet
493497

494498
def isConst = isSolved
495499
def isAlwaysEmpty = isSolved && elems.isEmpty
@@ -923,16 +927,16 @@ object CaptureSet:
923927
cs1.elems.filter(cs2.mightAccountFor) ++ cs2.elems.filter(cs1.mightAccountFor)
924928

925929
/** A capture set variable used to record the references hidden by a Fresh.Cap instance */
926-
class HiddenSet(initialHidden: Refs = emptyRefs)(using @constructorOnly ictx: Context)
930+
class HiddenSet(initialHidden: Refs = emptySet)(using @constructorOnly ictx: Context)
927931
extends Var(initialElems = initialHidden):
928932

929933
/** Apply function `f` to `elems` while setting `elems` to empty for the
930-
* duration. This is used to escape infinite recursions if two Fresh.Caps
934+
* duration. This is used to escape infinite recursions if two Frash.Caps
931935
* refer to each other in their hidden sets.
932936
*/
933937
override def processElems[T](f: Refs => T): T =
934938
val savedElems = elems
935-
elems = emptyRefs
939+
elems = emptySet
936940
try f(savedElems)
937941
finally elems = savedElems
938942
end HiddenSet

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ class CheckCaptures extends Recheck, SymTransformer:
622622
case _ => denot
623623

624624
// Don't allow update methods to be called unless the qualifier captures
625-
// an exclusive reference. TODO This should probably rolled into
625+
// contain an exclusive referenece. TODO This should probabkly rolled into
626626
// qualifier logic once we have it.
627627
if tree.symbol.isUpdateMethod && !qualType.captureSet.isExclusive then
628628
report.error(

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import NameKinds.ExistentialBinderName
1313
import NameOps.isImpureFunction
1414
import reporting.Message
1515
import util.SimpleIdentitySet.empty
16-
import CaptureSet.{Refs, emptyRefs, NarrowingCapabilityMap}
16+
import CaptureSet.{Refs, emptySet, NarrowingCapabilityMap}
1717
import dotty.tools.dotc.util.SimpleIdentitySet
1818

1919
/** A module for handling Fresh types. Fresh.Cap instances are top type that keep
@@ -43,14 +43,14 @@ object Fresh:
4343
private def ownerToHidden(owner: Symbol, reach: Boolean)(using Context): Refs =
4444
val ref = owner.termRef
4545
if reach then
46-
if ref.isTrackableRef then SimpleIdentitySet(ref.reach) else emptyRefs
46+
if ref.isTrackableRef then SimpleIdentitySet(ref.reach) else emptySet
4747
else
48-
if ref.isTracked then SimpleIdentitySet(ref) else emptyRefs
48+
if ref.isTracked then SimpleIdentitySet(ref) else emptySet
4949

5050
/** An extractor for "fresh" capabilities */
5151
object Cap:
5252

53-
def apply(initialHidden: Refs = emptyRefs)(using Context): CaptureRef =
53+
def apply(initialHidden: Refs = emptySet)(using Context): CaptureRef =
5454
if ccConfig.useSepChecks then
5555
AnnotatedType(defn.captureRoot.termRef, Annot(CaptureSet.HiddenSet(initialHidden)))
5656
else

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

+8-8
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import collection.mutable
77
import core.*
88
import Symbols.*, Types.*, Flags.*
99
import Contexts.*, Names.*, Flags.*, Symbols.*, Decorators.*
10-
import CaptureSet.{Refs, emptyRefs, HiddenSet}
10+
import CaptureSet.{Refs, emptySet, HiddenSet}
1111
import config.Printers.capt
1212
import StdNames.nme
1313
import util.{SimpleIdentitySet, EqHashMap, SrcPos}
@@ -150,7 +150,7 @@ class SepCheck(checker: CheckCaptures.CheckerAPI) extends tpd.TreeTraverser:
150150
/** The set of capabilities that are hidden by a polymorphic result type
151151
* of some previous definition.
152152
*/
153-
private var defsShadow: Refs = emptyRefs
153+
private var defsShadow: Refs = emptySet
154154

155155
/** A map from definitions to their internal result types.
156156
* Populated during separation checking traversal.
@@ -244,10 +244,10 @@ class SepCheck(checker: CheckCaptures.CheckerAPI) extends tpd.TreeTraverser:
244244
def hiddenByElem(elem: CaptureRef): Refs = elem match
245245
case Fresh.Cap(hcs) => hcs.elems.filter(!_.isRootCapability) ++ recur(hcs.elems)
246246
case ReadOnlyCapability(ref1) => hiddenByElem(ref1).map(_.readOnly)
247-
case _ => emptyRefs
247+
case _ => emptySet
248248

249249
def recur(refs: Refs): Refs =
250-
(emptyRefs /: refs): (elems, elem) =>
250+
(emptySet /: refs): (elems, elem) =>
251251
if seen.add(elem) then elems ++ hiddenByElem(elem) else elems
252252

253253
recur(refs)
@@ -336,7 +336,7 @@ class SepCheck(checker: CheckCaptures.CheckerAPI) extends tpd.TreeTraverser:
336336
def hiddenCaptures = formalCaptures(arg).hidden
337337
def clashFootprint = clashCaptures.footprint
338338
def hiddenFootprint = hiddenCaptures.footprint
339-
def declaredFootprint = deps(arg).map(captures(_)).foldLeft(emptyRefs)(_ ++ _).footprint
339+
def declaredFootprint = deps(arg).map(captures(_)).foldLeft(emptySet)(_ ++ _).footprint
340340
def footprintOverlap = hiddenFootprint.overlapWith(clashFootprint).deduct(declaredFootprint)
341341
report.error(
342342
em"""Separation failure: argument of type ${arg.nuType}
@@ -501,7 +501,7 @@ class SepCheck(checker: CheckCaptures.CheckerAPI) extends tpd.TreeTraverser:
501501
case AnnotatedType(parent, _) => explicitRefs(parent)
502502
case AndType(tp1, tp2) => explicitRefs(tp1) ++ explicitRefs(tp2)
503503
case OrType(tp1, tp2) => explicitRefs(tp1) ** explicitRefs(tp2)
504-
case _ => emptyRefs
504+
case _ => emptySet
505505

506506
/** Deduct some elements from `refs` according to the role of the checked type `tpe`:
507507
* - If the the type apears as a (result-) type of a definition of `x`, deduct
@@ -594,8 +594,8 @@ class SepCheck(checker: CheckCaptures.CheckerAPI) extends tpd.TreeTraverser:
594594
* be explicitly referenced or hidden in some other part.
595595
*/
596596
def checkParts(parts: List[Type]): Unit =
597-
var footprint: Refs = emptyRefs
598-
var hiddenSet: Refs = emptyRefs
597+
var footprint: Refs = emptySet
598+
var hiddenSet: Refs = emptySet
599599
var checked = 0
600600
for part <- parts do
601601

0 commit comments

Comments
 (0)