Skip to content

Commit 0b335cc

Browse files
jchybbishabosha
andauthored
Apply suggestions from code review
Co-authored-by: Jamie Thompson <bishbashboshjt@gmail.com>
1 parent 680e0d5 commit 0b335cc

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

docs/_docs/reference/metaprogramming/reflection.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ We can access the underlying typed AST of an `Expr` using the `asTerm` extension
4242
```
4343

4444
Similarly, you can change a `Term` back into an `Expr` with `.asExpr` (returning `Expr[Any]`)
45-
or `.asExprOf[T]` (returning `Expr[T]`, with an exception being thrown at runtime if the type does not conform).
45+
or `.asExprOf[T]` (returning `Expr[T]`, with an exception being thrown at macro-expansion time if the type does not conform).
4646

4747
## Constructing and Analysing trees
4848

@@ -88,9 +88,9 @@ The above is represented in the quotes reflect API by a `Block` (a subtype of `T
8888
You can see the whole hierarchy between different types of Trees in
8989
[`reflectModule` documentation](https://scala-lang.org/api/3.3_LTS/scala/quoted/Quotes$reflectModule.html#`).
9090

91-
You can also easily check the shape of code by printing out quoted code transformed into a Term:
91+
You can also check the shape of code by printing out quoted code transformed into a Term:
9292
```scala
93-
println( `{ scalaCode }.asTerm )
93+
println( '{ scalaCode }.asTerm )
9494
```
9595
Bear in mind this will always produce a Term. E.g.:
9696
```scala
@@ -139,7 +139,7 @@ Bear in mind that extractors and constructors for the same trees might be compri
139139
has `(Symbol, Option[Term])` arguments and `unapply` has `(String, TypeTree, Option[Term])` (if we want to obtain the symbol directly, we can call `.symbol` on the `ValDef`).
140140

141141
### Symbols
142-
To construct definition `Trees` we might have to create or use a `Symbol`. Symbols represent the named parts of the code, the declarations we can reference elsewhere later. Let’s try to create `val name: Int = 0` from scratch.
142+
To construct definition `Trees` we might have to create or use a `Symbol`. Symbols represent the "named" parts of the code, the declarations we can reference elsewhere later. Let’s try to create `val name: Int = 0` from scratch.
143143
To create a val like this, we need to first create a `Symbol` that matches the intended `Tree` type, so for a `ValDef` we would use the `Symbol.newVal` method:
144144
```scala
145145
import quotes.reflect._
@@ -249,7 +249,7 @@ and methods on instances of `Select` would be found in `SelectMethods`.
249249

250250
### Positions
251251

252-
The `Position` in the `quotes.reflect._` provides an `ofMacroExpansion` value. It corresponds
252+
The `Position` in the `quotes.reflect.*` provides an `ofMacroExpansion` value. It corresponds
253253
to the expansion site for macros. The macro authors can obtain various information
254254
about that expansion site. The example below shows how we can obtain position
255255
information such as the start line, the end line or even the source code at the

0 commit comments

Comments
 (0)