File tree 2 files changed +2
-24
lines changed
docs/docs/reference/metaprogramming 2 files changed +2
-24
lines changed Original file line number Diff line number Diff line change @@ -656,7 +656,7 @@ private def sumExpr(argsExpr: Expr[Seq[Int]])(using QuoteContext): Expr[Int] = a
656
656
657
657
#### Quoted patterns
658
658
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.
660
660
Patterns ` '{ ... } ` can be placed in any location where Scala expects a pattern.
661
661
662
662
For example
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ the scope where it is used.
26
26
``` scala
27
27
import scala .quoted ._
28
28
29
- inline def natConst (x : => Int ): Int = $ {natConstImpl(' {x})}
29
+ inline def natConst (inline x : Int ): Int = $ {natConstImpl(' {x})}
30
30
31
31
def natConstImpl (x : Expr [Int ])(using qctx : QuoteContext ): Expr [Int ] = {
32
32
import qctx .reflect ._
@@ -66,28 +66,6 @@ The method `qctx.reflect.Term.seal` provides a way to go back to a
66
66
must be set explicitly with a checked ` cast ` call. If the type does not conform
67
67
to it an exception will be thrown at runtime.
68
68
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
- ```
91
69
92
70
### Positions
93
71
You can’t perform that action at this time.
0 commit comments