Skip to content

Commit 67ee590

Browse files
committed
Fix levelOwner docs and logic
Also: Drop RefiningVar
1 parent 555089a commit 67ee590

File tree

3 files changed

+6
-14
lines changed

3 files changed

+6
-14
lines changed

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -423,9 +423,7 @@ extension (sym: Symbol)
423423
|| sym.is(Method, butNot = Accessor)
424424

425425
/** The owner of the current level. Qualifying owners are
426-
* - methods other than constructors and anonymous functions
427-
* - anonymous functions, provided they either define a local
428-
* root of type caps.Capability, or they are the rhs of a val definition.
426+
* - methods, other than accessors
429427
* - classes, if they are not staticOwners
430428
* - _root_
431429
*/

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

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -520,9 +520,7 @@ object CaptureSet:
520520
if elem.isRootCapability then !noUniversal
521521
else elem match
522522
case elem: TermRef if levelLimit.exists =>
523-
var sym = elem.symbol
524-
if sym.isLevelOwner then sym = sym.owner
525-
levelLimit.isContainedIn(sym.levelOwner)
523+
levelLimit.isContainedIn(elem.symbol.levelOwner)
526524
case elem: ThisType if levelLimit.exists =>
527525
levelLimit.isContainedIn(elem.cls.levelOwner)
528526
case ReachCapability(elem1) =>
@@ -622,13 +620,6 @@ object CaptureSet:
622620
override def toString = s"Var$id$elems"
623621
end Var
624622

625-
/** Variables that represent refinements of class parameters can have the universal
626-
* capture set, since they represent only what is the result of the constructor.
627-
* Test case: Without that tweak, logger.scala would not compile.
628-
*/
629-
class RefiningVar(directOwner: Symbol)(using Context) extends Var(directOwner):
630-
override def disallowRootCapability(handler: () => Context ?=> Unit)(using Context) = this
631-
632623
/** A variable that is derived from some other variable via a map or filter. */
633624
abstract class DerivedVar(owner: Symbol, initialElems: Refs)(using @constructorOnly ctx: Context)
634625
extends Var(owner, initialElems):

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,10 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
189189
val getterType =
190190
mapInferred(refine = false)(tp.memberInfo(getter)).strippedDealias
191191
RefinedType(core, getter.name,
192-
CapturingType(getterType, CaptureSet.RefiningVar(ctx.owner)))
192+
CapturingType(getterType,
193+
new CaptureSet.Var(ctx.owner):
194+
override def disallowRootCapability(handler: () => Context ?=> Unit)(using Context) = this
195+
))
193196
.showing(i"add capture refinement $tp --> $result", capt)
194197
else
195198
core

0 commit comments

Comments
 (0)