@@ -830,6 +830,11 @@ class Namer { typer: Typer =>
830830 def setNotNullInfos (infos : List [NotNullInfo ]): Unit =
831831 myNotNullInfos = infos
832832
833+ /** Cache for type signature if computed without forcing annotations
834+ * by `typeSigOnly`
835+ */
836+ private var knownTypeSig : Type = NoType
837+
833838 protected def typeSig (sym : Symbol ): Type = original match
834839 case original : ValDef =>
835840 if (sym.is(Module )) moduleValSig(sym)
@@ -1006,12 +1011,20 @@ class Namer { typer: Typer =>
10061011 val sym = denot.symbol
10071012 addAnnotations(sym)
10081013 addInlineInfo(sym)
1009- denot.info = typeSig(sym)
1014+ denot.info = knownTypeSig `orElse` typeSig(sym)
10101015 invalidateIfClashingSynthetic(denot)
10111016 normalizeFlags(denot)
10121017 Checking .checkWellFormed(sym)
10131018 denot.info = avoidPrivateLeaks(sym)
10141019 }
1020+
1021+ /** Just the type signature without forcing any of the other parts of
1022+ * this denotation. The denotation will still be completed later.
1023+ */
1024+ def typeSigOnly (sym : Symbol ): Type =
1025+ if ! knownTypeSig.exists then
1026+ knownTypeSig = typeSig(sym)
1027+ knownTypeSig
10151028 }
10161029
10171030 class TypeDefCompleter (original : TypeDef )(ictx : Context )
@@ -1974,10 +1987,12 @@ class Namer { typer: Typer =>
19741987 for params <- ddef.termParamss; param <- params do
19751988 val psym = symbolOfTree(param)
19761989 if needsTracked(psym, param, owningSym) then
1977- psym.setFlag(Tracked )
1978- setParamTrackedWithAccessors(psym, sym.maybeOwner.infoOrCompleter)
1990+ println(i " NEEDS TRACKED $psym in $owningSym in ${ctx.source}" )
1991+ if Feature .enabled(modularity) then
1992+ psym.setFlag(Tracked )
1993+ setParamTrackedWithAccessors(psym, sym.maybeOwner.infoOrCompleter)
19791994
1980- if Feature .enabled(modularity) then addTrackedIfNeeded(ddef, sym.maybeOwner)
1995+ if Feature .enabled(modularity) || true then addTrackedIfNeeded(ddef, sym.maybeOwner)
19811996
19821997 if isConstructor then
19831998 // set result type tree to unit, but take the current class as result type of the symbol
@@ -2030,30 +2045,25 @@ class Namer { typer: Typer =>
20302045 psym.setFlag(Tracked )
20312046 acc.setFlag(Tracked )
20322047
2033- /** `psym` needs tracked if it is referenced in any of the public signatures
2034- * of the defining class or when `psym` is a context bound witness with an
2035- * abstract type member
2048+ /** `psym` needs an inferred tracked if
2049+ * - it is a val parameter of a class or
2050+ * an evidence parameter of a context bound witness, and
2051+ * - its type contains an abstract type member.
20362052 */
20372053 def needsTracked (psym : Symbol , param : ValDef , owningSym : Symbol )(using Context ) =
2038- lazy val needsTrackedSimp = needsTrackedSimple(psym, param, owningSym)
2054+ lazy val accessorSyms = maybeParamAccessors(owningSym, psym)
2055+
2056+ def infoDontForceAnnots = psym.infoOrCompleter match
2057+ case completer : this .Completer => completer.typeSigOnly(psym)
2058+ case tpe => tpe
2059+
20392060 ! psym.is(Tracked )
20402061 && psym.isTerm
2041- && needsTrackedSimp
2042-
2043- private def needsTrackedSimple (psym : Symbol , param : ValDef , owningSym : Symbol )(using Context ): Boolean =
2044- val accessorSyms = maybeParamAccessors(owningSym, psym)
2045- (owningSym.isClass || owningSym.isAllOf(Given | Method ))
2046- && ! accessorSyms.exists(_.is(Mutable ))
2062+ && (owningSym.isClass || owningSym.isAllOf(Given | Method ))
2063+ && accessorSyms.forall(! _.is(Mutable ))
20472064 && (param.hasAttachment(ContextBoundParam ) || accessorSyms.exists(! _.isOneOf(PrivateLocal )))
2048- && psym.infoDontForceAnnotsAndInferred(param).memberNames(abstractTypeNameFilter).nonEmpty
2049-
2050- extension (sym : Symbol )
2051- private def infoDontForceAnnotsAndInferred (tree : DefTree )(using Context ): Type =
2052- sym.infoOrCompleter match
2053- case tpe if tree.mods.annotations.nonEmpty => tpe
2054- case tpe : LazyType if tpe.isExplicit => sym.info
2055- case tpe if sym.isType => sym.info
2056- case info => info
2065+ && infoDontForceAnnots.abstractTypeMembers.nonEmpty
2066+ end needsTracked
20572067
20582068 private def maybeParamAccessors (owner : Symbol , sym : Symbol )(using Context ): List [Symbol ] = owner.infoOrCompleter match
20592069 case info : ClassInfo =>
0 commit comments