@@ -652,42 +652,20 @@ class CheckCaptures extends Recheck, SymTransformer:
652
652
if sym.is(Method ) then
653
653
// If ident refers to a parameterless method, charge its cv to the environment
654
654
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)
659
657
mapResultRoots(super .recheckIdent(tree, pt), tree.symbol)
660
658
661
659
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)
665
661
super .recheckThis(tree, pt)
666
662
667
663
/** 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:
669
666
* 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`.
691
669
*/
692
670
private def markPathFree (ref : TermRef | ThisType , pt : Type , tree : Tree )(using Context ): Unit =
693
671
pt match
0 commit comments