Commit ec3cdad
authored
Unencode quote and splice trees (#17342)
We currently use the `Quote` and `Splice` ASTs for untyped quotes and
splices. Then when we type them we encode them into
`scala.quoted.runtime.Expr.{quote,splice,nestedSplice}`. This
non-semantic representation if fragile and the source of many past bug.
In this PR we change the internal representation of quotes and splices
to use the `Quote` and `Splice` ASTs as typed trees.
The core of this change in the AST representation and how we type them
in `QuotesAndSplices`. Other changes consist in adapting the code from
one representation to the other.
```diff
- case class Quote(quoted: Tree)(implicit @constructorOnly src: SourceFile) extends TermTree
+ case class Quote[+T <: Untyped] private[ast] (body: Tree[T])(implicit @constructorOnly src: SourceFile) extends TermTree[T]
- case class Splice(expr: Tree)(implicit @constructorOnly src: SourceFile) extends TermTree
+ case class Splice[+T <: Untyped] private[ast] (expr: Tree[T])(implicit @constructorOnly src: SourceFile) extends TermTree[T]
```
* We do not change the TASTy (file and reflection) representation of
quotes and splices. This is something that we should consider adding in
a future PR.
* We can use the simpler encoding of `splice` in all cases. The
additional `Quotes` in `nestedSplice` is not used.
* This does not change binary compatibility.File tree
42 files changed
+488
-455
lines changed- compiler
- src
- dotty/tools/dotc
- ast
- core/tasty
- inlines
- parsing
- printing
- quoted
- staging
- transform
- patmat
- typer
- scala/quoted/runtime/impl
- test-resources
- repl-macros
- repl
- staging/test-resources/repl-staging
- tests
- neg-macros
- pos-macros
- run-staging
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
42 files changed
+488
-455
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
157 | | - | |
158 | | - | |
159 | 157 | | |
160 | 158 | | |
161 | 159 | | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
162 | 164 | | |
163 | 165 | | |
164 | 166 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1986 | 1986 | | |
1987 | 1987 | | |
1988 | 1988 | | |
1989 | | - | |
| 1989 | + | |
1990 | 1990 | | |
1991 | 1991 | | |
1992 | 1992 | | |
1993 | 1993 | | |
1994 | 1994 | | |
1995 | | - | |
| 1995 | + | |
1996 | 1996 | | |
1997 | 1997 | | |
1998 | 1998 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1026 | 1026 | | |
1027 | 1027 | | |
1028 | 1028 | | |
1029 | | - | |
1030 | | - | |
| 1029 | + | |
1031 | 1030 | | |
1032 | 1031 | | |
1033 | 1032 | | |
1034 | 1033 | | |
1035 | 1034 | | |
1036 | | - | |
1037 | | - | |
1038 | | - | |
1039 | | - | |
| 1035 | + | |
1040 | 1036 | | |
1041 | 1037 | | |
1042 | 1038 | | |
1043 | 1039 | | |
1044 | 1040 | | |
1045 | 1041 | | |
1046 | | - | |
1047 | | - | |
1048 | | - | |
1049 | | - | |
1050 | | - | |
1051 | | - | |
1052 | | - | |
1053 | | - | |
1054 | | - | |
1055 | | - | |
1056 | 1042 | | |
1057 | 1043 | | |
1058 | 1044 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
677 | 678 | | |
678 | 679 | | |
679 | 680 | | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
680 | 735 | | |
681 | 736 | | |
682 | 737 | | |
| |||
1087 | 1142 | | |
1088 | 1143 | | |
1089 | 1144 | | |
| 1145 | + | |
| 1146 | + | |
1090 | 1147 | | |
1091 | 1148 | | |
1092 | 1149 | | |
| |||
1257 | 1314 | | |
1258 | 1315 | | |
1259 | 1316 | | |
| 1317 | + | |
| 1318 | + | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
1260 | 1325 | | |
1261 | 1326 | | |
1262 | 1327 | | |
| |||
1494 | 1559 | | |
1495 | 1560 | | |
1496 | 1561 | | |
| 1562 | + | |
| 1563 | + | |
| 1564 | + | |
| 1565 | + | |
1497 | 1566 | | |
1498 | 1567 | | |
1499 | 1568 | | |
| |||
1635 | 1704 | | |
1636 | 1705 | | |
1637 | 1706 | | |
| 1707 | + | |
| 1708 | + | |
| 1709 | + | |
| 1710 | + | |
1638 | 1711 | | |
1639 | 1712 | | |
1640 | 1713 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
173 | 179 | | |
174 | 180 | | |
175 | 181 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | 114 | | |
119 | 115 | | |
120 | 116 | | |
| |||
401 | 397 | | |
402 | 398 | | |
403 | 399 | | |
| 400 | + | |
| 401 | + | |
404 | 402 | | |
405 | 403 | | |
406 | 404 | | |
| |||
622 | 620 | | |
623 | 621 | | |
624 | 622 | | |
625 | | - | |
626 | | - | |
627 | | - | |
628 | | - | |
629 | | - | |
630 | | - | |
631 | | - | |
632 | | - | |
633 | 623 | | |
634 | 624 | | |
635 | 625 | | |
| |||
711 | 701 | | |
712 | 702 | | |
713 | 703 | | |
714 | | - | |
715 | | - | |
716 | | - | |
717 | | - | |
718 | 704 | | |
719 | 705 | | |
720 | 706 | | |
| |||
772 | 758 | | |
773 | 759 | | |
774 | 760 | | |
775 | | - | |
776 | | - | |
777 | | - | |
778 | | - | |
779 | 761 | | |
780 | 762 | | |
781 | 763 | | |
| |||
Lines changed: 20 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
665 | 665 | | |
666 | 666 | | |
667 | 667 | | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
668 | 688 | | |
669 | 689 | | |
670 | 690 | | |
| |||
Lines changed: 18 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1267 | 1267 | | |
1268 | 1268 | | |
1269 | 1269 | | |
| 1270 | + | |
| 1271 | + | |
| 1272 | + | |
| 1273 | + | |
| 1274 | + | |
| 1275 | + | |
| 1276 | + | |
| 1277 | + | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
1270 | 1285 | | |
1271 | 1286 | | |
1272 | 1287 | | |
| |||
1283 | 1298 | | |
1284 | 1299 | | |
1285 | 1300 | | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
1286 | 1304 | | |
1287 | 1305 | | |
1288 | 1306 | | |
| |||
0 commit comments