@@ -2020,12 +2020,10 @@ class Namer { typer: Typer =>
2020
2020
lazy val isRefInSignatures =
2021
2021
psym.maybeOwner.isPrimaryConstructor
2022
2022
&& isReferencedInPublicSignatures(psym)
2023
+ lazy val needsTrackedSimp = needsTrackedSimple(psym, param, owningSym)
2023
2024
! psym.is(Tracked )
2024
2025
&& psym.isTerm
2025
- && (
2026
- abstractContextBound
2027
- || isRefInSignatures
2028
- )
2026
+ && needsTrackedSimp
2029
2027
2030
2028
/** Under x.modularity, we add `tracked` to context bound witnesses and
2031
2029
* explicit evidence parameters that have abstract type members
@@ -2036,6 +2034,13 @@ class Namer { typer: Typer =>
2036
2034
&& (param.hasAttachment(ContextBoundParam ) || (psym.isOneOf(GivenOrImplicit ) && ! accessorSyms.forall(_.isOneOf(PrivateLocal ))))
2037
2035
&& psym.info.memberNames(abstractTypeNameFilter).nonEmpty
2038
2036
2037
+ private def needsTrackedSimple (psym : Symbol , param : ValDef , owningSym : Symbol )(using Context ): Boolean =
2038
+ val accessorSyms = maybeParamAccessors(owningSym, psym)
2039
+ (owningSym.isClass || owningSym.isAllOf(Given | Method ))
2040
+ && ! accessorSyms.exists(_.is(Mutable ))
2041
+ && (param.hasAttachment(ContextBoundParam ) || ! accessorSyms.forall(_.isOneOf(PrivateLocal )))
2042
+ && psym.info.memberNames(abstractTypeNameFilter).nonEmpty
2043
+
2039
2044
extension (sym : Symbol )
2040
2045
private def infoWithForceNonInferingCompleter (using Context ): Type = sym.infoOrCompleter match
2041
2046
case tpe : LazyType if tpe.isExplicit => sym.info
@@ -2083,8 +2088,7 @@ class Namer { typer: Typer =>
2083
2088
def setTrackedConstrParam (param : ValDef )(using Context ): Unit =
2084
2089
val sym = symbolOfTree(param)
2085
2090
sym.maybeOwner.maybeOwner.infoOrCompleter match
2086
- case info : ClassInfo
2087
- if ! sym.is(Tracked ) && isContextBoundWitnessWithAbstractMembers(sym, param, sym.maybeOwner.maybeOwner) =>
2091
+ case info : ClassInfo if needsTracked(sym, param, sym.maybeOwner.maybeOwner) =>
2088
2092
typr.println(i " set tracked $param, $sym: ${sym.info} containing ${sym.info.memberNames(abstractTypeNameFilter).toList}" )
2089
2093
setParamTrackedWithAccessors(sym, info)
2090
2094
case _ =>
0 commit comments