File tree 2 files changed +4
-4
lines changed
docs/docs/reference/contextual
2 files changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -91,7 +91,7 @@ The implementation of `summonAll` as a macro can be show below assuming that we
91
91
have the given instances for our primitive types:
92
92
93
93
``` scala
94
- def summonAll [T : Type ](using qctx : QuoteContext ): List [Expr [Eq [_]]] = t match {
94
+ def summonAll [T : Type ](using qctx : QuoteContext ): List [Expr [Eq [_]]] = Type .of[ T ] match {
95
95
case ' [String *: tpes] => ' { summon[Eq [String ]] } :: summonAll[tpes]
96
96
case ' [Int *: tpes] => ' { summon[Eq [Int ]] } :: summonAll[tpes]
97
97
case ' [tpe *: tpes] => derived[tpe] :: summonAll[tpes]
@@ -169,7 +169,7 @@ object Eq {
169
169
def eqv (x : T , y : T ): Boolean = body(x, y)
170
170
}
171
171
172
- def summonAll [T : Type ](using qctx : QuoteContext ): List [Expr [Eq [_]]] = t match {
172
+ def summonAll [T : Type ](using qctx : QuoteContext ): List [Expr [Eq [_]]] = Type .of[ T ] match {
173
173
case ' [String *: tpes] => ' { summon[Eq [String ]] } :: summonAll[tpes]
174
174
case ' [Int *: tpes] => ' { summon[Eq [Int ]] } :: summonAll[tpes]
175
175
case ' [tpe *: tpes] => derived[tpe] :: summonAll[tpes]
@@ -217,7 +217,7 @@ object Eq {
217
217
}
218
218
219
219
object Macro3 {
220
- extension [T ](inline x : T )
220
+ extension [T ](inline x : T )
221
221
inline def === (inline y : T )(using eq : Eq [T ]): Boolean = eq.eqv(x, y)
222
222
223
223
implicit inline def eqGen [T ]: Eq [T ] = $ { Eq .derived[T ] }
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ object Eq {
25
25
def eqv (x : T , y : T ): Boolean = body(x, y)
26
26
}
27
27
28
- def summonAll [T ]( using t : Type [ T ]) (using qctx : QuoteContext ): List [Expr [Eq [_]]] = t match {
28
+ def summonAll [T : Type ] (using qctx : QuoteContext ): List [Expr [Eq [_]]] = Type .of[ T ] match {
29
29
case ' [String *: tpes] => ' { summon[Eq [String ]] } :: summonAll[tpes]
30
30
case ' [Int *: tpes] => ' { summon[Eq [Int ]] } :: summonAll[tpes]
31
31
case ' [tpe *: tpes] => derived[tpe] :: summonAll[tpes]
You can’t perform that action at this time.
0 commit comments