- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1.1k
Simpler inference for tracked #22972
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
3348b8f    to
    2dc8ada      
    Compare
  
    | lazy val isRefInSignatures = | ||
| psym.maybeOwner.isPrimaryConstructor | ||
| && isReferencedInPublicSignatures(psym) | ||
| lazy val needsTrackedSimp = needsTrackedSimple(psym, param, owningSym) | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see why you need a lazy val here? A def would do as weell and be more efficient? Or just inline the rhs.
| && psym.info.memberNames(abstractTypeNameFilter).nonEmpty | ||
| && !accessorSyms.exists(_.is(Mutable)) | ||
| && (param.hasAttachment(ContextBoundParam) || accessorSyms.exists(!_.isOneOf(PrivateLocal))) | ||
| && psym.infoDontForceAnnotsAndInferred(param).memberNames(abstractTypeNameFilter).nonEmpty | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not: abstractTypeNames.nonEmpty?
| sym.infoOrCompleter match | ||
| case tpe if tree.mods.annotations.nonEmpty => tpe | ||
| case tpe: LazyType if tpe.isExplicit => sym.info | ||
| case tpe if sym.isType => sym.info | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this not rendundant wrt the last line?
| acc(false, tpe) | ||
| private def infoDontForceAnnotsAndInferred(tree: DefTree)(using Context): Type = | ||
| sym.infoOrCompleter match | ||
| case tpe if tree.mods.annotations.nonEmpty => tpe | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we find a more finegrained exclusion that avoids the NoSymbol?
| @@ -0,0 +1,6 @@ | |||
| import scala.language.experimental.modularity | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be good to add some more tests that exercise the precise conditions that infer tracked.
606bfe9    to
    f1b836e      
    Compare
  
    Break out code for testing tracked inference independently of x.modularity
Check parameters whether they need to be tracked only under x.modularity.
f1b836e    to
    069dd61      
    Compare
  
    There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did some changes to simplify it further and update the doc page to reflect the new behavior.
| Summary of changes over original PR: 
 | 
Change
trackedinference to simpler heuristic: always infertrackedfor a parameter if its type has an abstract type member.Tested it with
modularityturned on and the only bug I noticed was eager typing of annotations, which I patched by not inferringtrackedfor annotated parameters.