Skip to content

Commit 5e158f5

Browse files
committed
Don't add another refinement for tracked class parameters
1 parent c427246 commit 5e158f5

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,9 @@ extension (cls: ClassSymbol) {
645645
case TypeRef(prefix: ThisType, _) if prefix.cls == cls => locals
646646
case TypeRef(prefix, _) => locals.map(AsSeenFromMap(prefix, cls.owner))
647647
case _ => locals
648+
649+
def refiningGetterNamed(name: Name)(using Context): Symbol =
650+
cls.info.decls.lookup(name).suchThat(_.isRefiningParamAccessor).symbol
648651
}
649652

650653
extension (sym: Symbol) {

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -983,9 +983,10 @@ class CheckCaptures extends Recheck, SymTransformer:
983983
var refined: Type = core
984984
var allCaptures: CaptureSet = initCs ++ cls.capturesImpliedByFields(core).refs
985985
for (getterName, argType) <- mt.paramNames.lazyZip(argTypes) do
986-
val getter = cls.info.member(getterName).suchThat(_.isRefiningParamAccessor).symbol
986+
val getter = cls.refiningGetterNamed(getterName)
987987
if !getter.is(Private) && getter.hasTrackedParts then
988-
refined = refined.refinedOverride(getterName, argType.unboxed)
988+
if !getter.is(Tracked) then
989+
refined = refined.refinedOverride(getterName, argType.unboxed)
989990
// We can assume unboxed since the use set contributed by field selection is also the capture set
990991
// So unboxing will not add anything to the use sets.
991992
// This trick is also the principal reason why we can't make refineConstructorInstance

0 commit comments

Comments
 (0)