@@ -278,6 +278,9 @@ class Namer { typer: Typer =>
278278                if  rhs.isEmpty ||  flags.is(Opaque ) then  flags |=  Deferred 
279279            if  flags.is(Param ) then  tree.rhs else  analyzeRHS(tree.rhs)
280280
281+         def  isNonInferingTree (tree : ValOrDefDef ):  Boolean  = 
282+           ! tree.tpt.isEmpty ||  tree.mods.isOneOf(TermParamOrAccessor )
283+ 
281284        //  to complete a constructor, move one context further out -- this
282285        //  is the context enclosing the class. Note that the context in which a
283286        //  constructor is recorded and the context in which it is completed are
@@ -291,6 +294,7 @@ class Namer { typer: Typer =>
291294
292295        val  completer  =  tree match 
293296          case  tree : TypeDef  =>  TypeDefCompleter (tree)(cctx)
297+           case  tree : ValOrDefDef  if  isNonInferingTree(tree) =>  NonInferingCompleter (tree)(cctx)
294298          case  _ =>  Completer (tree)(cctx)
295299        val  info  =  adjustIfModule(completer, tree)
296300        createOrRefine[Symbol ](tree, name, flags, ctx.owner, _ =>  info,
@@ -1736,6 +1740,10 @@ class Namer { typer: Typer =>
17361740    }
17371741  }
17381742
1743+   class  NonInferingCompleter (original : ValOrDefDef )(ictx : Context ) extends  Completer (original)(ictx) {
1744+     override  def  isNonInfering :  Boolean  =  true 
1745+   }
1746+ 
17391747  /**  Possible actions to perform when deciding on a forwarder for a member */  
17401748  private  enum  CanForward : 
17411749    case  Yes 
@@ -1994,14 +2002,13 @@ class Namer { typer: Typer =>
19942002  def  needsTracked (sym : Symbol , param : ValDef )(using  Context ) = 
19952003    ! sym.is(Tracked )
19962004    &&  sym.isTerm
1997-     &&  sym.maybeOwner.isPrimaryConstructor
1998-     //  && !sym.flags.is(Synthetic)
1999-     //  && !sym.maybeOwner.flags.is(Synthetic)
2000-     &&  ! sym.maybeOwner.maybeOwner.flags.is(Synthetic )
20012005    &&  (
20022006      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)
20052012    )
20062013
20072014  /**  Under x.modularity, we add `tracked` to context bound witnesses 
@@ -2011,6 +2018,11 @@ class Namer { typer: Typer =>
20112018    param.hasAttachment(ContextBoundParam )
20122019    &&  sym.info.memberNames(abstractTypeNameFilter).nonEmpty
20132020
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+ 
20142026  /**  Under x.modularity, we add `tracked` to term parameters whose types are referenced 
20152027   *  in public signatures of the defining class 
20162028   */  
@@ -2022,20 +2034,10 @@ class Namer { typer: Typer =>
20222034        case  info : ClassInfo  => 
20232035          info.decls.filter(_.isTerm).filter(_.isPublic)
20242036            .filter(_ !=  sym.maybeOwner)
2025-             .exists(d =>  tpeContainsSymbolRef(d.info , accessorSyms))
2037+             .exists(d =>  tpeContainsSymbolRef(d.infoWithForceNonInferingCompleter , accessorSyms))
20262038        case  _ =>  false 
20272039    checkOwnerMemberSignatures(owner)
20282040
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- 
20392041  private  def  namedTypeWithPrefixContainsSymbolRef (tpe : Type , syms : List [Symbol ])(using  Context ):  Boolean  =  tpe match 
20402042    case  tpe : NamedType  =>  tpe.prefix.exists &&  tpeContainsSymbolRef(tpe.prefix, syms)
20412043    case  _ =>  false 
0 commit comments