-
Notifications
You must be signed in to change notification settings - Fork 1.1k
More changes to protected accessors #4603
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
Hi Allan, I did some improvements to the protected accessor scheme. Can you use this one as a basis for the partial functions PR? |
Several fixes detected during refactorings of inliner
Use inline$x inline$x_= protected$x protected$x_= instead of inline_get$x inline_set$x protected_get$x protected_set$x Advantage: more idiomatic, and it's possible to make this work on untyped trees as well. The old scheme would have required accessors for every operator assignment when extending it to untyped trees.
Rebased on top of master which now contains #4597 |
private def rewire(reference: RefTree, accessor: Symbol)(implicit ctx: Context): Tree = { | ||
reference match { | ||
case Select(qual, _) => qual.select(accessor) | ||
case Ident(name) => ref(accessor) |
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.
Do you need to desugar the Identifier here like in tpd.becomes
?
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.
No, since we always to refer to given accessor
.
val sym = ctx.newSymbol(owner, name, Synthetic | Method, info, coord = pos).entered | ||
if (sym.allOverriddenSymbols.exists(!_.is(Deferred))) sym.setFlag(Override) | ||
sym | ||
} | ||
|
||
/** An accessor symbol, create a fresh one unless one exists already */ | ||
private def accessorSymbol(owner: Symbol, accessorName: TermName, accessorInfo: Type, accessed: Symbol)(implicit ctx: Context) = { | ||
def refersToAccessed(sym: Symbol) = accessedBy.get(sym) == Some(accessed) |
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.
accessedBy.get(sym).contains(accessed)
?
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.
Ah, yes. I'll roll that into another PR.
Some fixes in the AccessProxies scheme that were discovered when revising the inliner.