-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Simplify enclosedInlineds #4990
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
Simplify enclosedInlineds #4990
Conversation
inlineContext already normalized most of InlinedCalls, normalize all of it instead. The new code isn't much more complex, the only tricky bit is assuming we don't need to normalize the pre-normalized list. In fact, this can be simplified further!
If we normalize too early w will not have the full inline stack which implies that we may not be able to use it for improving the error messages. Though it is possible that normalized stack is enough. @odersky WDYT? |
The existing code already normalizes the stack too much for your use case. It might have a rationale, I haven't found it yet, tho I'm not done studying this. OTOH, maybe the context chain has enough information anyway. If not, we can change again, but not to the existing code. EDIT: after investigation I see the idea. If one does need the full stack, it seems one just need fix override def inlineContext(call: Tree)(implicit ctx: Context): Context =
ctx.fresh.setProperty(InlinedCalls, call :: ctx.property(InlinedCalls).getOrElse(Nil)) and add tests.
|
case Nil => Nil | ||
/** Record an enclosing inlined call. | ||
* EmptyTree calls (for parameters) cancel the next-enclosing call in the list instead of being added to it. | ||
* We assume parameters are never nested inside parameters. |
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.
WIP further experiments suggest this can't be true, even tho this code works.
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.
After normalization, we should not have them, so it should be fine or the normalization was not performed correctly.
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.
True after normalization — I thought that was also true before normalization, but that was wrong.
WIP waiting full tests, then I explain why this is a refactoring.
Bring both
inlineContext
andenclosingInlineds
from O(n) to O(1) without complicating the code.Noticed while reviewing #4949.