Commit 5120755
Quotes reflect: Allow to return DefDef from a val symbol tree (scala#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]1 parent 965f06a commit 5120755
File tree
5 files changed
+56
-6
lines changed- compiler/src/dotty/tools/dotc/quoted/reflect
- library/src/scala/quoted
- tests/pos-macros/i22584
5 files changed
+56
-6
lines changedLines changed: 7 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
| 48 | + | |
49 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
50 | 56 | | |
51 | 57 | | |
52 | 58 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3945 | 3945 | | |
3946 | 3946 | | |
3947 | 3947 | | |
3948 | | - | |
3949 | | - | |
3950 | | - | |
3951 | | - | |
3952 | | - | |
| 3948 | + | |
| 3949 | + | |
| 3950 | + | |
| 3951 | + | |
| 3952 | + | |
| 3953 | + | |
3953 | 3954 | | |
3954 | 3955 | | |
3955 | 3956 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
0 commit comments