Skip to content

Commit c8f51e7

Browse files
committed
Drop switch on newScheme, drop code that's no longer used.
1 parent 8aeec6a commit c8f51e7

File tree

1 file changed

+7
-29
lines changed

1 file changed

+7
-29
lines changed

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

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -652,42 +652,20 @@ class CheckCaptures extends Recheck, SymTransformer:
652652
if sym.is(Method) then
653653
// If ident refers to a parameterless method, charge its cv to the environment
654654
includeCallCaptures(sym, sym.info, tree)
655-
else if !sym.isStatic then
656-
if ccConfig.newScheme && sym.exists
657-
then markPathFree(sym.termRef, pt, tree)
658-
else markFree(sym, pathRef(sym.termRef, pt), tree)
655+
else if sym.exists && !sym.isStatic then
656+
markPathFree(sym.termRef, pt, tree)
659657
mapResultRoots(super.recheckIdent(tree, pt), tree.symbol)
660658

661659
override def recheckThis(tree: This, pt: Type)(using Context): Type =
662-
if ccConfig.newScheme
663-
then markPathFree(tree.tpe.asInstanceOf[ThisType], pt, tree)
664-
else markFree(pathRef(tree.tpe.asInstanceOf[ThisType], pt), tree)
660+
markPathFree(tree.tpe.asInstanceOf[ThisType], pt, tree)
665661
super.recheckThis(tree, pt)
666662

667663
/** Add all selections and also any `.rd modifier implied by the expected
668-
* type `pt` to `base`. Example:
664+
* type `pt` to `ref`. Expand the marked tree accordingly to take account of
665+
* the added path. Example:
669666
* If we have `x` and the expected type says we select that with `.a.b`
670-
* where `b` is a read-only method, we charge `x.a.b.rd` instead of `x`.
671-
*/
672-
private def pathRef(base: TermRef | ThisType, pt: Type)(using Context): Capability =
673-
def addSelects(ref: TermRef | ThisType, pt: Type): Capability = pt match
674-
case pt: PathSelectionProto if ref.isTracked =>
675-
if pt.select.symbol.isReadOnlyMethod then
676-
ref.readOnly
677-
else
678-
// if `ref` is not tracked then the selection could not give anything new
679-
// class SerializationProxy in stdlib-cc/../LazyListIterable.scala has an example where this matters.
680-
addSelects(ref.select(pt.select.symbol).asInstanceOf[TermRef], pt.pt)
681-
case _ => ref
682-
val ref: Capability = addSelects(base, pt)
683-
if ref.derivesFromMutable && pt.isValueType && !pt.isMutableType
684-
then ref.readOnly
685-
else ref
686-
687-
/** Add all selections and also any `.rd modifier implied by the expected
688-
* type `pt` to `base`. Example:
689-
* If we have `x` and the expected type says we select that with `.a.b`
690-
* where `b` is a read-only method, we charge `x.a.b.rd` instead of `x`.
667+
* where `b` is a read-only method, we charge `x.a.b.rd` for tree `x.a.b`
668+
* instead of just charging `x`.
691669
*/
692670
private def markPathFree(ref: TermRef | ThisType, pt: Type, tree: Tree)(using Context): Unit =
693671
pt match

0 commit comments

Comments
 (0)