@@ -128,6 +128,12 @@ trait CaptureRef extends TypeProxy, ValueType:
128128 final def isExclusive (using Context ): Boolean =
129129 ! isReadOnly && (isRootCapability || captureSetOfInfo.isExclusive)
130130
131+ /** The owning symbol associated with a capability this is
132+ * - for Fresh capabilities: the owner of the hidden set
133+ * - for TermRefs and TypeRefs: the symbol it refers to
134+ * - for derived and path capabilities: the owner of the underlying capability
135+ * - otherwise NoSymbol
136+ */
131137 final def ccOwner (using Context ): Symbol = this match
132138 case root.Fresh (hidden) =>
133139 hidden.owner
@@ -143,7 +149,12 @@ trait CaptureRef extends TypeProxy, ValueType:
143149 case _ =>
144150 NoSymbol
145151
146- final def adjustedOwner (using Context ): Symbol =
152+ /** The symbol that represents the level closest-enclosing ccOwner.
153+ * Symbols representing levels are
154+ * - class symbols, but not inner (non-static) module classes
155+ * - method symbols, but not accessors or constructors
156+ */
157+ final def levelOwner (using Context ): Symbol =
147158 def adjust (owner : Symbol ): Symbol =
148159 if ! owner.exists
149160 || owner.isClass && (! owner.is(Flags .Module ) || owner.isStatic)
@@ -296,7 +307,7 @@ trait CaptureRef extends TypeProxy, ValueType:
296307 case x @ root.Fresh (hidden) =>
297308 def levelOK =
298309 if ccConfig.useFreshLevels && ! CCState .ignoreFreshLevels then
299- val yOwner = y.adjustedOwner
310+ val yOwner = y.levelOwner
300311 yOwner.isStaticOwner || x.ccOwner.isContainedIn(yOwner)
301312 else
302313 ! y.stripReadOnly.isCap
0 commit comments