Skip to content

Commit a0ddaab

Browse files
committed
Add some comments and fix others
1 parent 23839ba commit a0ddaab

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,23 @@ object Capabilities:
152152
val hiddenSet = CaptureSet.HiddenSet(owner, this: @unchecked)
153153
// fails initialization check without the @unchecked
154154

155+
/** Is this fresh cap (definitely) classified? If that's the case, the
156+
* classifier cannot be changed anymore.
157+
* We need to distinguish `FreshCap`s that can still be classified from
158+
* ones that cannot. Once a `FreshCap` is part of a constant capture set,
159+
* it gets classified by the type that prefixes the set and that classification
160+
* cannot be changed anymore. But other `FreshCap`s are created as members of
161+
* variable sets and then their classification status is open and can be
162+
* constrained further.
163+
*/
155164
private[Capabilities] var isClassified = false
156165

157166
override def equals(that: Any) = that match
158167
case that: FreshCap => this eq that
159168
case _ => false
160169

170+
/** Is this fresh cap at the right level to be able to subsume `ref`?
171+
*/
161172
def acceptsLevelOf(ref: Capability)(using Context): Boolean =
162173
if ccConfig.useFreshLevels && !CCState.collapseFresh then
163174
val refOwner = ref.levelOwner
@@ -166,6 +177,9 @@ object Capabilities:
166177
case ResultCap(_) | _: ParamRef => false
167178
case _ => true
168179

180+
/** Classify this FreshCap as `cls`, provided `isClassified` is still false.
181+
* @param freeze Deterermines future `isClassified` state.
182+
*/
169183
def adoptClassifier(cls: ClassSymbol, freeze: Boolean)(using Context): Unit =
170184
if !isClassified then
171185
hiddenSet.adoptClassifier(cls)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ sealed abstract class CaptureSet extends Showable:
446446
case _ =>
447447

448448
/** All capabilities of this set except those Termrefs and FreshCaps that
449-
* are boundby `mt`.
449+
* are bound by `mt`.
450450
*/
451451
def freeInResult(mt: MethodicType)(using Context): CaptureSet =
452452
filter:

0 commit comments

Comments
 (0)