-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Handle pickled forward references in pickled expressions #16855
Conversation
661bc28
to
eb92c52
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.
/cc @sjrd since this seems like it will affect tasty-query
val b = ${ | ||
val a = '{ | ||
(1: Int) match | ||
case x @ (y: Int) => 0 | ||
} | ||
a | ||
} | ||
|
||
(1: Int) match | ||
case x @ (y: Int) => 0 |
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.
The test case in #16843 is easier to understand/debug, so I would add it too even if we want to test more complex cases.
current | ||
// If current does not exist it is beacause this is a pickled expression | ||
// and the owner is located outside the expression (i.e. pickled quote). | ||
current.orElse(ctx.owner) |
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.
This could hide bugs if we're not in fact in a pickled quote. I think it'd be clearer if we stored the quote owner instead. Something like:
/** If this is a pickled quote, the owner of the quote, otherwise NoSymbol. */
private var rootOwner: Symbol = NoSymbol
...
def unpickle(mode: UnpickleMode)(using Context): List[Tree] = {
if mode != UnpickleMode.TopLevel then rootOwner = ctx.owner
...
}
...
class OwnerTree(val addr: Addr, tag: Int, reader: TreeReader, val end: Addr) {
...
try search(children, rootOwner)
...
}
We do not generate |
eb92c52
to
3c74eec
Compare
To compute forward references it was assumed that the owner of that symbol can be found in the TASTy. This is not always the case with TASTy expressions of pickled quotes. The owner might be outside the quote, in this case the context already has the owner of the referenced symbol. These are local symbols defined at the top-level of the TASTy. Fixes scala#16843
3c74eec
to
96bfb69
Compare
To compute forward references it was assumed that the owner of that symbol can be found in the TASTy. This is not always the case with TASTy expressions of pickled quotes. The owner might be outside the quote, in this case the context already has the owner of the referenced symbol. These are local symbols defined at the top-level of the TASTy.
Fixes #16843