Skip to content

Commit 99c63ad

Browse files
committed
Update Scala 3 macro reflection
1 parent 38e5441 commit 99c63ad

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

_overviews/scala3-macros/tutorial/index.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,19 @@ abstractions and offers more fine-grained control.
2020

2121
- [Compile-time operations][compiletime] offer additional metaprogramming utilities that can be used within `inline` methods (for example to improve error reporting), without having to define a macro.
2222

23-
- Starting from `inline`-methods, [macros][macros] are programs that explicitly operate on programs.
23+
- Starting from `inline` methods, [macros][macros] are programs that explicitly operate on programs.
2424

2525
- Macros can be defined in terms of a _high-level_ API of [quoted expressions][quotes], that admits simple construction and deconstruction of programs expressions.
2626

27-
- Macros can also be defined in terms of a more _low-level_ API of [TASTy Reflection][tasty], that allows detailed inspection of programs.
27+
- Macros can also be defined in terms of a more _low-level_ API of [Reflection][reflection], that allows detailed inspection of programs.
2828

2929
> The tutorial uses the API of Scala 3.0.0-M3. The API had many small changes in this revision.
3030
31-
> 🚧 We are still in the process of writing the tutorial. You can [help us improve it][contributing] 🚧
31+
> 🚧 We are still in the process of writing the tutorial. You can [help us][contributing] 🚧
3232
3333
[contributing]: {% link scala3/contribute-to-docs.md %}
3434
[compiletime]: {% link _overviews/scala3-macros/tutorial/compiletime.md %}
3535
[inline]: {% link _overviews/scala3-macros/tutorial/inline.md %}
3636
[macros]: {% link _overviews/scala3-macros/tutorial/macros.md %}
3737
[quotes]: {% link _overviews/scala3-macros/tutorial/quotes.md %}
38-
[tasty]: {% link _overviews/scala3-macros/tutorial/reflection.md %}
38+
[reflection]: {% link _overviews/scala3-macros/tutorial/reflection.md %}
Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
---
22
type: section
3-
title: Tasty Reflection
3+
title: Reflection
44
num: 6
55

66
previous-page: quotes
77
---
88

99
The reflection API provides a more complex and comprehensive view on the structure of the code.
10-
It provides a view on the *Typed Abstract Syntax Trees* **TASTy** and their properties such as types, symbols, positions and comments.
10+
It provides a view on the *Typed Abstract Syntax Trees* and their properties such as types, symbols, positions and comments.
1111

1212
## How to use the API
1313

@@ -16,19 +16,19 @@ We can use `scala.quoted.quotes` to import it.
1616

1717
```scala
1818
def pow(x: Expr[Int])(using Quotes): Expr[Int] = {
19-
import quotes.tasty._ // Import Tree, Type, Symbol, Position, .....
19+
import quotes.reflect._ // Import Tree, Type, Symbol, Position, .....
2020
...
2121
}
2222
```
2323

2424
This will import all the types and modules (with extension methods) of the API.
2525

26-
The full imported API can be found here: [Reflection](https://dotty.epfl.ch/api/scala/tasty/Reflection.html)
26+
The full imported API can be found here: [Reflection](reflectModule)
2727

2828
For example to find what is a `Term`, we can see in the hierarchy that it is a subtype of `Statement` which is a subtype of `Tree`.
29-
If we look into the [`TermMethods`](https://dotty.epfl.ch/api/scala/tasty/Reflection/TermMethods.html) we will find all the extension methods that are defined for `Term` such as `Term.tpe` which returns a `Type`.
30-
As it is a subtype of `Tree` we can also look into the [`TreeMethods`](http://dotty.epfl.ch/api/scala/tasty/Reflection/TreeMethods.html) to find more methods such as `Tree.pos`.
31-
Each type also a module with some _static-ish_ methods, for example in the [TypeModule](http://dotty.epfl.ch/api/scala/tasty/Reflection/TypeModule.html) we can find the method `Type.of[T]` with will create an instance of `Type` containing `T`.
29+
If we look into the [`TermMethods`](TermMethods) we will find all the extension methods that are defined for `Term` such as `Term.tpe` which returns a `Type`.
30+
As it is a subtype of `Tree` we can also look into the [`TreeMethods`](TreeMethods) to find more methods such as `Tree.pos`.
31+
Each type also a module with some _static-ish_ methods, for example in the [`TypeReprModule`](TypeReprModule) we can find the method `TypeRepr.of[T]` with will create an instance of `Type` containing `T`.
3232

3333

3434
## Relation with expressions
@@ -39,3 +39,9 @@ Each type also a module with some _static-ish_ methods, for example in the [Type
3939

4040
## Examples
4141
*Coming soon*
42+
43+
44+
[reflectModule]: https://dotty.epfl.ch/api/scala/quoted/Quotes$reflectModule.html?query=trait%20reflectModule
45+
[TreeMethods]: https://dotty.epfl.ch/api/scala/quoted/Quotes$reflectModule$TreeMethods.html
46+
[TermMethods]: https://dotty.epfl.ch/api/scala/quoted/Quotes$reflectModule$TermMethods.html
47+
[TypeReprModule]: https://dotty.epfl.ch/api/scala/quoted/Quotes$reflectModule$TypeReprModule.html

0 commit comments

Comments
 (0)