@@ -2030,65 +2030,24 @@ class Namer { typer: Typer =>
20302030 * abstract type member
20312031 */
20322032 def needsTracked (psym : Symbol , param : ValDef , owningSym : Symbol )(using Context ) =
2033- lazy val abstractContextBound = isContextBoundWitnessWithAbstractMembers(psym, param, owningSym)
2034- lazy val isRefInSignatures =
2035- psym.maybeOwner.isPrimaryConstructor
2036- && isReferencedInPublicSignatures(psym)
20372033 lazy val needsTrackedSimp = needsTrackedSimple(psym, param, owningSym)
20382034 ! psym.is(Tracked )
2039- && psym.isTerm
2040- && needsTrackedSimp
2041-
2042- /** Under x.modularity, we add `tracked` to context bound witnesses and
2043- * explicit evidence parameters that have abstract type members
2044- */
2045- private def isContextBoundWitnessWithAbstractMembers (psym : Symbol , param : ValDef , owningSym : Symbol )(using Context ): Boolean =
2046- val accessorSyms = maybeParamAccessors(owningSym, psym)
2047- (owningSym.isClass || owningSym.isAllOf(Given | Method ))
2048- && (param.hasAttachment(ContextBoundParam ) || (psym.isOneOf(GivenOrImplicit ) && ! accessorSyms.forall(_.isOneOf(PrivateLocal ))))
2049- && psym.info.memberNames(abstractTypeNameFilter).nonEmpty
2035+ && psym.isTerm
2036+ && needsTrackedSimp
20502037
20512038 private def needsTrackedSimple (psym : Symbol , param : ValDef , owningSym : Symbol )(using Context ): Boolean =
20522039 val accessorSyms = maybeParamAccessors(owningSym, psym)
20532040 (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
2041+ && ! accessorSyms.exists(_.is(Mutable ))
2042+ && (param.hasAttachment(ContextBoundParam ) || accessorSyms.exists( ! _.isOneOf(PrivateLocal )))
2043+ && psym.info.memberNames(abstractTypeNameFilter).nonEmpty
20572044
20582045 extension (sym : Symbol )
20592046 private def infoWithForceNonInferingCompleter (using Context ): Type = sym.infoOrCompleter match
20602047 case tpe : LazyType if tpe.isExplicit => sym.info
20612048 case tpe if sym.isType => sym.info
20622049 case info => info
20632050
2064- /** Under x.modularity, we add `tracked` to term parameters whose types are
2065- * referenced in public signatures of the defining class
2066- */
2067- private def isReferencedInPublicSignatures (sym : Symbol )(using Context ): Boolean =
2068- val owner = sym.maybeOwner.maybeOwner
2069- val accessorSyms = maybeParamAccessors(owner, sym)
2070- def checkOwnerMemberSignatures (owner : Symbol ): Boolean =
2071- owner.infoOrCompleter match
2072- case info : ClassInfo =>
2073- info.decls.filter(_.isPublic)
2074- .filter(_ != sym.maybeOwner)
2075- .exists { decl =>
2076- tpeContainsSymbolRef(decl.infoWithForceNonInferingCompleter, accessorSyms)
2077- }
2078- case _ => false
2079- checkOwnerMemberSignatures(owner)
2080-
2081- /** Check if any of syms are referenced in tpe */
2082- private def tpeContainsSymbolRef (tpe : Type , syms : List [Symbol ])(using Context ): Boolean =
2083- val acc = new ExistsAccumulator (
2084- { tpe => tpe.termSymbol.exists && syms.contains(tpe.termSymbol) },
2085- StopAt .Static ,
2086- forceLazy = false
2087- ) {
2088- override def apply (acc : Boolean , tpe : Type ): Boolean = super .apply(acc, tpe.safeDealias)
2089- }
2090- acc(false , tpe)
2091-
20922051 private def maybeParamAccessors (owner : Symbol , sym : Symbol )(using Context ): List [Symbol ] = owner.infoOrCompleter match
20932052 case info : ClassInfo =>
20942053 info.decls.lookupAll(sym.name).filter(d => d.is(ParamAccessor )).toList
0 commit comments