@@ -14,7 +14,7 @@ You may find all you need without using TASTy Reflect.
14
14
## API: From quotes and splices to TASTy reflect trees and back
15
15
16
16
With ` quoted.Expr ` and ` quoted.Type ` we can compute code but also analyze code
17
- by inspecting the ASTs. [ Macros] ( ./macros.md ) provides the guarantee that the
17
+ by inspecting the ASTs. [ Macros] ( ./macros.md ) provide the guarantee that the
18
18
generation of code will be type-correct. Using TASTy Reflect will break these
19
19
guarantees and may fail at macro expansion time, hence additional explicit
20
20
checks must be done.
@@ -64,8 +64,7 @@ To easily know which extractors are needed, the `showExtractors` method on a
64
64
The method ` qctx.tasty.Term.seal ` provides a way to go back to a
65
65
` quoted.Expr[Any] ` . Note that the type is ` Expr[Any] ` . Consequently, the type
66
66
must be set explicitly with a checked ` cast ` call. If the type does not conform
67
- to it an exception will be thrown. In the code above, we could have replaced
68
- ` Expr(n) ` by ` xTree.seal.cast[Int] ` .
67
+ to it an exception will be thrown at runtime.
69
68
70
69
### Obtaining the underlying argument
71
70
@@ -92,8 +91,8 @@ macro(this.checkCondition())
92
91
93
92
### Positions
94
93
95
- The tasty context provides a ` rootPosition ` value. For macros it corresponds to
96
- the expansion site. The macro authors can obtain various information about that
94
+ The tasty context provides a ` rootPosition ` value. It corresponds to
95
+ the expansion site for macros . The macro authors can obtain various information about that
97
96
expansion site. The example below shows how we can obtain position information
98
97
such as the start line, the end line or even the source code at the expansion
99
98
point.
@@ -117,10 +116,10 @@ def macroImpl()(qctx: QuoteContext): Expr[Unit] = {
117
116
### Tree Utilities
118
117
119
118
`scala.tasty.reflect` contains three facilities for tree traversal and
120
- transformations .
119
+ transformation .
121
120
122
121
`TreeAccumulator` ties the knot of a traversal. By calling `foldOver(x, tree))`
123
- we can dive in the `tree` node and start accumulating values of type `X` (e.g.,
122
+ we can dive into the `tree` node and start accumulating values of type `X` (e.g.,
124
123
of type List [Symbol ] if we want to collect symbols). The code below, for
125
124
example, collects the pattern variables of a tree.
126
125
@@ -142,8 +141,8 @@ but without returning any value. Finally a `TreeMap` performs a transformation.
142
141
#### Let
143
142
144
143
`scala.tasty.Reflection` also offers a method `let` that allows us
145
- to bind the `rhs` to a `val` and use it in `body`. Additionally , `lets` binds
146
- the given `terms` to names and use them in the `body`. Their type definitions
144
+ to bind the `rhs` (right - hand side) to a `val` and use it in `body`. Additionally , `lets` binds
145
+ the given `terms` to names and allows to use them in the `body`. Their type definitions
147
146
are shown below :
148
147
149
148
```scala
0 commit comments