Skip to content

Commit 67bd66f

Browse files
Merge pull request #10208 from dotty-staging/update-reflect-docs
Update docs to the new semantics of inline parameters
2 parents ac88f0e + cce52ed commit 67bd66f

File tree

2 files changed

+2
-24
lines changed

2 files changed

+2
-24
lines changed

docs/docs/reference/metaprogramming/macros.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ private def sumExpr(argsExpr: Expr[Seq[Int]])(using QuoteContext): Expr[Int] = a
656656

657657
#### Quoted patterns
658658

659-
Quoted pattens allow to deconstruct complex code that contains a precise structure, types or methods.
659+
Quoted pattens allow deconstructing complex code that contains a precise structure, types or methods.
660660
Patterns `'{ ... }` can be placed in any location where Scala expects a pattern.
661661

662662
For example

docs/docs/reference/metaprogramming/tasty-reflect.md

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ the scope where it is used.
2626
```scala
2727
import scala.quoted._
2828

29-
inline def natConst(x: => Int): Int = ${natConstImpl('{x})}
29+
inline def natConst(inline x: Int): Int = ${natConstImpl('{x})}
3030

3131
def natConstImpl(x: Expr[Int])(using qctx: QuoteContext): Expr[Int] = {
3232
import qctx.reflect._
@@ -66,28 +66,6 @@ The method `qctx.reflect.Term.seal` provides a way to go back to a
6666
must be set explicitly with a checked `cast` call. If the type does not conform
6767
to it an exception will be thrown at runtime.
6868

69-
### Obtaining the underlying argument
70-
71-
A macro can access the tree of the actual argument passed on the call-site. The
72-
`underlyingArgument` method on a `Term` object will give access to the tree
73-
defining the expression passed. For example the code below matches a selection
74-
operation expression passed while calling the `macro` below.
75-
76-
```scala
77-
inline def macro(param: => Boolean): Unit = ${ macroImpl('param) }
78-
79-
def macroImpl(param: Expr[Boolean])(using qctx: QuoteContext): Expr[Unit] = {
80-
import qctx.reflect._
81-
import util._
82-
83-
param.unseal.underlyingArgument match {
84-
case t @ Apply(Select(lhs, op), rhs :: Nil) => ..
85-
}
86-
}
87-
88-
// example
89-
macro(this.checkCondition())
90-
```
9169

9270
### Positions
9371

0 commit comments

Comments
 (0)