@@ -2003,13 +2003,9 @@ class Namer { typer: Typer =>
2003
2003
/** Try to infer if the parameter needs a `tracked` modifier
2004
2004
*/
2005
2005
def needsTracked (psym : Symbol , param : ValDef , owningSym : Symbol )(using Context ) =
2006
- // println(i"Checking if $psym needs tracked")
2007
2006
lazy val abstractContextBound = isContextBoundWitnessWithAbstractMembers(psym, param, owningSym)
2008
2007
lazy val isRefInSignatures =
2009
2008
psym.maybeOwner.isPrimaryConstructor
2010
- // && !psym.flags.is(Synthetic)
2011
- // && !psym.maybeOwner.flags.is(Synthetic)
2012
- // && !psym.maybeOwner.maybeOwner.flags.is(Synthetic)
2013
2009
&& isReferencedInPublicSignatures(psym)
2014
2010
! psym.is(Tracked )
2015
2011
&& psym.isTerm
@@ -2046,29 +2042,21 @@ class Namer { typer: Typer =>
2046
2042
case _ => false
2047
2043
checkOwnerMemberSignatures(owner)
2048
2044
2049
- private def namedTypeWithPrefixContainsSymbolRef (tpe : Type , syms : List [Symbol ])(using Context ): Boolean = tpe match
2050
- case tpe : NamedType => tpe.prefix.exists && tpeContainsSymbolRef(tpe.prefix, syms)
2051
- case _ => false
2052
-
2053
- private def tpeContainsSymbolRef (tpe0 : Type , syms : List [Symbol ])(using Context ): Boolean =
2054
- val tpe = tpe0.dropAlias.safeDealias
2055
- tpe match
2056
- case ExprType (resType) => tpeContainsSymbolRef(resType, syms)
2057
- case m : MethodOrPoly =>
2058
- m.paramInfos.exists(tpeContainsSymbolRef(_, syms))
2059
- || tpeContainsSymbolRef(m.resultType, syms)
2060
- case r @ RefinedType (parent, _, refinedInfo) => tpeContainsSymbolRef(parent, syms) || tpeContainsSymbolRef(refinedInfo, syms)
2061
- case TypeBounds (lo, hi) => tpeContainsSymbolRef(lo, syms) || tpeContainsSymbolRef(hi, syms)
2062
- case t : Type =>
2063
- tpe.termSymbol.exists && syms.contains(tpe.termSymbol)
2064
- || tpe.argInfos.exists(tpeContainsSymbolRef(_, syms))
2065
- || namedTypeWithPrefixContainsSymbolRef(tpe, syms)
2066
-
2067
- private def maybeParamAccessors (owner : Symbol , sym : Symbol )(using Context ): List [Symbol ] =
2068
- owner.infoOrCompleter match
2069
- case info : ClassInfo =>
2070
- info.decls.lookupAll(sym.name).filter(d => d.is(ParamAccessor )).toList
2071
- case _ => List .empty
2045
+ /** Check if any of syms are referenced in tpe */
2046
+ private def tpeContainsSymbolRef (tpe : Type , syms : List [Symbol ])(using Context ): Boolean =
2047
+ val acc = new ExistsAccumulator (
2048
+ { tpe => tpe.termSymbol.exists && syms.contains(tpe.termSymbol) },
2049
+ StopAt .Static ,
2050
+ forceLazy = false
2051
+ ) {
2052
+ override def apply (acc : Boolean , tpe : Type ): Boolean = super .apply(acc, tpe.safeDealias)
2053
+ }
2054
+ acc(false , tpe)
2055
+
2056
+ private def maybeParamAccessors (owner : Symbol , sym : Symbol )(using Context ): List [Symbol ] = owner.infoOrCompleter match
2057
+ case info : ClassInfo =>
2058
+ info.decls.lookupAll(sym.name).filter(d => d.is(ParamAccessor )).toList
2059
+ case _ => List .empty
2072
2060
2073
2061
/** Under x.modularity, set every context bound evidence parameter of a class to be tracked,
2074
2062
* provided it has a type that has an abstract type member. Reset private and local flags
0 commit comments