@@ -2035,65 +2035,24 @@ class Namer { typer: Typer =>
20352035 * abstract type member
20362036 */
20372037 def needsTracked (psym : Symbol , param : ValDef , owningSym : Symbol )(using Context ) =
2038- lazy val abstractContextBound = isContextBoundWitnessWithAbstractMembers(psym, param, owningSym)
2039- lazy val isRefInSignatures =
2040- psym.maybeOwner.isPrimaryConstructor
2041- && isReferencedInPublicSignatures(psym)
20422038 lazy val needsTrackedSimp = needsTrackedSimple(psym, param, owningSym)
20432039 ! psym.is(Tracked )
2044- && psym.isTerm
2045- && needsTrackedSimp
2046-
2047- /** Under x.modularity, we add `tracked` to context bound witnesses and
2048- * explicit evidence parameters that have abstract type members
2049- */
2050- private def isContextBoundWitnessWithAbstractMembers (psym : Symbol , param : ValDef , owningSym : Symbol )(using Context ): Boolean =
2051- val accessorSyms = maybeParamAccessors(owningSym, psym)
2052- (owningSym.isClass || owningSym.isAllOf(Given | Method ))
2053- && (param.hasAttachment(ContextBoundParam ) || (psym.isOneOf(GivenOrImplicit ) && ! accessorSyms.forall(_.isOneOf(PrivateLocal ))))
2054- && psym.info.memberNames(abstractTypeNameFilter).nonEmpty
2040+ && psym.isTerm
2041+ && needsTrackedSimp
20552042
20562043 private def needsTrackedSimple (psym : Symbol , param : ValDef , owningSym : Symbol )(using Context ): Boolean =
20572044 val accessorSyms = maybeParamAccessors(owningSym, psym)
20582045 (owningSym.isClass || owningSym.isAllOf(Given | Method ))
2059- && ! accessorSyms.exists(_.is(Mutable ))
2060- && (param.hasAttachment(ContextBoundParam ) || ! accessorSyms.forall( _.isOneOf(PrivateLocal )))
2061- && psym.info.memberNames(abstractTypeNameFilter).nonEmpty
2046+ && ! accessorSyms.exists(_.is(Mutable ))
2047+ && (param.hasAttachment(ContextBoundParam ) || accessorSyms.exists( ! _.isOneOf(PrivateLocal )))
2048+ && psym.info.memberNames(abstractTypeNameFilter).nonEmpty
20622049
20632050 extension (sym : Symbol )
20642051 private def infoWithForceNonInferingCompleter (using Context ): Type = sym.infoOrCompleter match
20652052 case tpe : LazyType if tpe.isExplicit => sym.info
20662053 case tpe if sym.isType => sym.info
20672054 case info => info
20682055
2069- /** Under x.modularity, we add `tracked` to term parameters whose types are
2070- * referenced in public signatures of the defining class
2071- */
2072- private def isReferencedInPublicSignatures (sym : Symbol )(using Context ): Boolean =
2073- val owner = sym.maybeOwner.maybeOwner
2074- val accessorSyms = maybeParamAccessors(owner, sym)
2075- def checkOwnerMemberSignatures (owner : Symbol ): Boolean =
2076- owner.infoOrCompleter match
2077- case info : ClassInfo =>
2078- info.decls.filter(_.isPublic)
2079- .filter(_ != sym.maybeOwner)
2080- .exists { decl =>
2081- tpeContainsSymbolRef(decl.infoWithForceNonInferingCompleter, accessorSyms)
2082- }
2083- case _ => false
2084- checkOwnerMemberSignatures(owner)
2085-
2086- /** Check if any of syms are referenced in tpe */
2087- private def tpeContainsSymbolRef (tpe : Type , syms : List [Symbol ])(using Context ): Boolean =
2088- val acc = new ExistsAccumulator (
2089- { tpe => tpe.termSymbol.exists && syms.contains(tpe.termSymbol) },
2090- StopAt .Static ,
2091- forceLazy = false
2092- ) {
2093- override def apply (acc : Boolean , tpe : Type ): Boolean = super .apply(acc, tpe.safeDealias)
2094- }
2095- acc(false , tpe)
2096-
20972056 private def maybeParamAccessors (owner : Symbol , sym : Symbol )(using Context ): List [Symbol ] = owner.infoOrCompleter match
20982057 case info : ClassInfo =>
20992058 info.decls.lookupAll(sym.name).filter(d => d.is(ParamAccessor )).toList
0 commit comments