@@ -2034,12 +2034,10 @@ class Namer { typer: Typer =>
2034
2034
lazy val isRefInSignatures =
2035
2035
psym.maybeOwner.isPrimaryConstructor
2036
2036
&& isReferencedInPublicSignatures(psym)
2037
+ lazy val needsTrackedSimp = needsTrackedSimple(psym, param, owningSym)
2037
2038
! psym.is(Tracked )
2038
2039
&& psym.isTerm
2039
- && (
2040
- abstractContextBound
2041
- || isRefInSignatures
2042
- )
2040
+ && needsTrackedSimp
2043
2041
2044
2042
/** Under x.modularity, we add `tracked` to context bound witnesses and
2045
2043
* explicit evidence parameters that have abstract type members
@@ -2050,6 +2048,13 @@ class Namer { typer: Typer =>
2050
2048
&& (param.hasAttachment(ContextBoundParam ) || (psym.isOneOf(GivenOrImplicit ) && ! accessorSyms.forall(_.isOneOf(PrivateLocal ))))
2051
2049
&& psym.info.memberNames(abstractTypeNameFilter).nonEmpty
2052
2050
2051
+ private def needsTrackedSimple (psym : Symbol , param : ValDef , owningSym : Symbol )(using Context ): Boolean =
2052
+ val accessorSyms = maybeParamAccessors(owningSym, psym)
2053
+ (owningSym.isClass || owningSym.isAllOf(Given | Method ))
2054
+ && ! accessorSyms.exists(_.is(Mutable ))
2055
+ && (param.hasAttachment(ContextBoundParam ) || ! accessorSyms.forall(_.isOneOf(PrivateLocal )))
2056
+ && psym.info.memberNames(abstractTypeNameFilter).nonEmpty
2057
+
2053
2058
extension (sym : Symbol )
2054
2059
private def infoWithForceNonInferingCompleter (using Context ): Type = sym.infoOrCompleter match
2055
2060
case tpe : LazyType if tpe.isExplicit => sym.info
@@ -2097,8 +2102,7 @@ class Namer { typer: Typer =>
2097
2102
def setTrackedConstrParam (param : ValDef )(using Context ): Unit =
2098
2103
val sym = symbolOfTree(param)
2099
2104
sym.maybeOwner.maybeOwner.infoOrCompleter match
2100
- case info : ClassInfo
2101
- if ! sym.is(Tracked ) && isContextBoundWitnessWithAbstractMembers(sym, param, sym.maybeOwner.maybeOwner) =>
2105
+ case info : ClassInfo if needsTracked(sym, param, sym.maybeOwner.maybeOwner) =>
2102
2106
typr.println(i " set tracked $param, $sym: ${sym.info} containing ${sym.info.memberNames(abstractTypeNameFilter).toList}" )
2103
2107
setParamTrackedWithAccessors(sym, info)
2104
2108
case _ =>
0 commit comments