@@ -278,6 +278,9 @@ class Namer { typer: Typer =>
278
278
if rhs.isEmpty || flags.is(Opaque ) then flags |= Deferred
279
279
if flags.is(Param ) then tree.rhs else analyzeRHS(tree.rhs)
280
280
281
+ def isNonInferingTree (tree : ValOrDefDef ): Boolean =
282
+ ! tree.tpt.isEmpty || tree.mods.isOneOf(TermParamOrAccessor )
283
+
281
284
// to complete a constructor, move one context further out -- this
282
285
// is the context enclosing the class. Note that the context in which a
283
286
// constructor is recorded and the context in which it is completed are
@@ -291,6 +294,7 @@ class Namer { typer: Typer =>
291
294
292
295
val completer = tree match
293
296
case tree : TypeDef => TypeDefCompleter (tree)(cctx)
297
+ case tree : ValOrDefDef if isNonInferingTree(tree) => NonInferingCompleter (tree)(cctx)
294
298
case _ => Completer (tree)(cctx)
295
299
val info = adjustIfModule(completer, tree)
296
300
createOrRefine[Symbol ](tree, name, flags, ctx.owner, _ => info,
@@ -1736,6 +1740,10 @@ class Namer { typer: Typer =>
1736
1740
}
1737
1741
}
1738
1742
1743
+ class NonInferingCompleter (original : ValOrDefDef )(ictx : Context ) extends Completer (original)(ictx) {
1744
+ override def isNonInfering : Boolean = true
1745
+ }
1746
+
1739
1747
/** Possible actions to perform when deciding on a forwarder for a member */
1740
1748
private enum CanForward :
1741
1749
case Yes
@@ -1994,14 +2002,13 @@ class Namer { typer: Typer =>
1994
2002
def needsTracked (sym : Symbol , param : ValDef )(using Context ) =
1995
2003
! sym.is(Tracked )
1996
2004
&& sym.isTerm
1997
- && sym.maybeOwner.isPrimaryConstructor
1998
- // && !sym.flags.is(Synthetic)
1999
- // && !sym.maybeOwner.flags.is(Synthetic)
2000
- && ! sym.maybeOwner.maybeOwner.flags.is(Synthetic )
2001
2005
&& (
2002
2006
isContextBoundWitnessWithAbstractMembers(sym, param)
2003
- || isReferencedInPublicSignatures(sym)
2004
- || isPassedToTrackedParentParameter(sym, param)
2007
+ || sym.maybeOwner.isPrimaryConstructor
2008
+ // && !sym.flags.is(Synthetic)
2009
+ // && !sym.maybeOwner.flags.is(Synthetic)
2010
+ // && !sym.maybeOwner.maybeOwner.flags.is(Synthetic)
2011
+ && isReferencedInPublicSignatures(sym)
2005
2012
)
2006
2013
2007
2014
/** Under x.modularity, we add `tracked` to context bound witnesses
@@ -2011,6 +2018,11 @@ class Namer { typer: Typer =>
2011
2018
param.hasAttachment(ContextBoundParam )
2012
2019
&& sym.info.memberNames(abstractTypeNameFilter).nonEmpty
2013
2020
2021
+ extension (sym : Symbol )
2022
+ def infoWithForceNonInferingCompleter (using Context ): Type = sym.infoOrCompleter match
2023
+ case tpe : LazyType if tpe.isNonInfering => sym.info
2024
+ case info => info
2025
+
2014
2026
/** Under x.modularity, we add `tracked` to term parameters whose types are referenced
2015
2027
* in public signatures of the defining class
2016
2028
*/
@@ -2022,20 +2034,10 @@ class Namer { typer: Typer =>
2022
2034
case info : ClassInfo =>
2023
2035
info.decls.filter(_.isTerm).filter(_.isPublic)
2024
2036
.filter(_ != sym.maybeOwner)
2025
- .exists(d => tpeContainsSymbolRef(d.info , accessorSyms))
2037
+ .exists(d => tpeContainsSymbolRef(d.infoWithForceNonInferingCompleter , accessorSyms))
2026
2038
case _ => false
2027
2039
checkOwnerMemberSignatures(owner)
2028
2040
2029
- def isPassedToTrackedParentParameter (sym : Symbol , param : ValDef )(using Context ): Boolean =
2030
- // TODO(kπ) Add tracked if the param is passed as a tracked arg in parent. Can we touch the inheritance terms?
2031
- val owner = sym.maybeOwner.maybeOwner
2032
- val accessorSyms = maybeParamAccessors(owner, sym)
2033
- owner.infoOrCompleter match
2034
- // case info: ClassInfo =>
2035
- // info.parents.foreach(println)
2036
- // info.parents.exists(tpeContainsSymbolRef(_, accessorSyms))
2037
- case _ => false
2038
-
2039
2041
private def namedTypeWithPrefixContainsSymbolRef (tpe : Type , syms : List [Symbol ])(using Context ): Boolean = tpe match
2040
2042
case tpe : NamedType => tpe.prefix.exists && tpeContainsSymbolRef(tpe.prefix, syms)
2041
2043
case _ => false
0 commit comments