Skip to content

Conversation

tgodzik
Copy link

@tgodzik tgodzik commented Sep 1, 2025

Backports scala#22603 to the 3.3.7.

PR submitted by the release tooling.
[skip ci]

…22603)

During the `Getters` phase, the compiler replaces class member vals with
defs. Meanwhile `.tree` returns a tree most recently associated with a
symbol (if currently compiled), or one read from tasty (if compiled
before). An interesting thing happens in the issue - since all of the
files are tried being compiled in one compilation run, the file with a
macro call is suspended, and then the macro and the MyClass class
definition are compiled to the end (also including the `Getters` phase,
where the tree stops being a ValDef).

Initially I thought about manually replacing that returned DefDef with a
ValDef in quotes reflection (like what happens when the tree is not
available), but that would have been pointless - there would be little
use of calling `.tree` on a symbol if we cannot read the rhs of the
definition. Returning raw DefDef seems like a less bad choice,
especially `.tree` is meant to be for power users anyway, and is full of
other, more dangerous warts.
[Cherry-picked 4788641]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants