@@ -9,7 +9,7 @@ implement a type class `derived` method using macros only. We follow the same
9
9
example of deriving ` Eq ` instances and for simplicity we support a ` Product `
10
10
type e.g., a case class ` Person ` . The low-level method we will use to implement
11
11
the ` derived ` method exploits quotes, splices of both expressions and types and
12
- the ` scala.quoted.matching.summonExpr ` method which is the equivalent of
12
+ the ` scala.quoted.Expr.summon ` method which is the equivalent of
13
13
` summonFrom ` . The former is suitable for use in a quote context, used within
14
14
macros.
15
15
@@ -44,7 +44,7 @@ from the signature. The body of the `derived` method is shown below:
44
44
given derived [T : Type ](using qctx : QuoteContext ) as Expr [Eq [T ]] = {
45
45
import qctx .tasty ._
46
46
47
- val ev : Expr [Mirror .Of [T ]] = summonExpr (using ' [Mirror .Of [T ]]).get
47
+ val ev : Expr [Mirror .Of [T ]] = Expr .summon (using ' [Mirror .Of [T ]]).get
48
48
49
49
ev match {
50
50
case ' { $m : Mirror .ProductOf [T ] { type MirroredElemTypes = $elementTypes }} =>
@@ -70,7 +70,7 @@ given derived[T: Type](using qctx: QuoteContext) as Expr[Eq[T]] = {
70
70
71
71
Note, that in the ` inline ` case we can merely write
72
72
` summonAll[m.MirroredElemTypes] ` inside the inline method but here, since
73
- ` summonExpr ` is required, we can extract the element types in a macro fashion.
73
+ ` Expr.summon ` is required, we can extract the element types in a macro fashion.
74
74
Being inside a macro, our first reaction would be to write the code below. Since
75
75
the path inside the type argument is not stable this cannot be used:
76
76
@@ -178,7 +178,7 @@ object Eq {
178
178
given derived [T : Type ](using qctx : QuoteContext ) as Expr [Eq [T ]] = {
179
179
import qctx .tasty ._
180
180
181
- val ev : Expr [Mirror .Of [T ]] = summonExpr (using ' [Mirror .Of [T ]]).get
181
+ val ev : Expr [Mirror .Of [T ]] = Expr .summon (using ' [Mirror .Of [T ]]).get
182
182
183
183
ev match {
184
184
case ' { $m : Mirror .ProductOf [T ] { type MirroredElemTypes = $elementTypes }} =>
0 commit comments