-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix #7110: Fix splice overload #8561
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
Fix #7110: Fix splice overload #8561
Conversation
36e74c5
to
3e3bb1d
Compare
37f0bff
to
b89405c
Compare
test performance with #quotes please |
Performance test finished successfully: Visit http://dotty-bench.epfl.ch/8561 to see the changes. Benchmarks is based on merging with master (64d6536) |
fd5ec93
to
36253dc
Compare
test performance with #quotes please |
performance test scheduled: 3 job(s) in queue, 1 running. |
Performance test finished successfully: Visit http://dotty-bench.epfl.ch/8561/ to see the changes. Benchmarks is based on merging with master (8a42819) |
be33572
to
789344e
Compare
To avoid wrong member selection when unpickling we must have qualifiers that have the same type as when it was pickled. This implies that we cannot expand the holes during unpickling as the expansion of a qualifier could have a more precise type. To be able to unpickle a hole without expanding it we must know its type, hence it must be pickled. Once the pickled quote has been unpickled, we first replace all the type splices. After the types are properly set we expand all the term holes. Changes * Types of holes are pickled in TASTy * Pickled quotes are unpickled and then the holes are expanded * Improved debugging info for unpickled quotes
789344e
to
fd7ff85
Compare
test performance with #quotes please |
performance test scheduled: 1 job(s) in queue, 1 running. |
Performance test finished successfully: Visit http://dotty-bench.epfl.ch/8561/ to see the changes. Benchmarks is based on merging with master (8a42819) |
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.
Otherwise, LGTM
val Inlined(call, Nil, expnasion) = unpickled | ||
val inlineCtx = inlineContext(call) | ||
val expansion1 = spliceTypes(expnasion, splices)(using inlineCtx) | ||
val expansion2 = spliceTerms(expansion1, splices)(using inlineCtx) |
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.
Small opt: can we just do one pass for splicing?
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, that was the first approach I tried. We need the types to be known when we expand the term holes as some of them may take some type parameters that the user inspects. Note that spliceTypes
is a no-op if the quote does not have type splices.
apply(tp.widenTermRefExpr) | ||
case tp => | ||
mapOver(tp) | ||
} |
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.
Will approximation of the hole type have consequences on member resolution in unpickling?
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.
Yes, the consequence is that when unpickling we use the same known bounds of the types to resolve members selection as was done in typed. This is the key to make sure they do not change.
// Make sure trees and positions are fully loaded | ||
new TreeTraverser { | ||
def traverse(tree: Tree)(implicit ctx: Context): Unit = traverseChildren(tree) | ||
}.traverse(tree) |
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.
What will happen if we remove the code above? Maybe add a doc for consequences if the action is not taken.
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.
Some symbols and positions are not loaded early enough. Not sure why though. But it has been like that since the start. Dimitry mentioned the need for this for loading trees from tasty in general and we have keep this mechanism so far.
Without the splices `QuoteUnpickler` is just a copy of the `DottyUnpickler`.
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.
LGTM
To avoid wrong member selection when unpickling we must have qualifiers that have the same type as when it was pickled. This implies that we cannot expand the holes during unpickling as
the expansion of a qualifier could have a more precise type. To be able to unpickle a hole
without expanding it we must know its type, hence it must be pickled.
Once the pickled quote has been unpickled, we first replace all the type splices. After the
types are properly set we expand all the term holes.
Changes