Skip to content

Commit 80597a2

Browse files
Merge pull request #10395 from dotty-staging/fix-derivation-macro-docs
Fix examples in derivation-macro.md
2 parents f0afb47 + 4637614 commit 80597a2

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

docs/docs/reference/contextual/derivation-macro.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ The implementation of `summonAll` as a macro can be show below assuming that we
9191
have the given instances for our primitive types:
9292

9393
```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 {
9595
case '[String *: tpes] => '{ summon[Eq[String]] } :: summonAll[tpes]
9696
case '[Int *: tpes] => '{ summon[Eq[Int]] } :: summonAll[tpes]
9797
case '[tpe *: tpes] => derived[tpe] :: summonAll[tpes]
@@ -169,7 +169,7 @@ object Eq {
169169
def eqv(x: T, y: T): Boolean = body(x, y)
170170
}
171171

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 {
173173
case '[String *: tpes] => '{ summon[Eq[String]] } :: summonAll[tpes]
174174
case '[Int *: tpes] => '{ summon[Eq[Int]] } :: summonAll[tpes]
175175
case '[tpe *: tpes] => derived[tpe] :: summonAll[tpes]
@@ -217,7 +217,7 @@ object Eq {
217217
}
218218

219219
object Macro3 {
220-
extension [T](inline x: T)
220+
extension [T](inline x: T)
221221
inline def === (inline y: T)(using eq: Eq[T]): Boolean = eq.eqv(x, y)
222222

223223
implicit inline def eqGen[T]: Eq[T] = ${ Eq.derived[T] }

tests/run-macros/i8007/Macro_3.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ object Eq {
2525
def eqv(x: T, y: T): Boolean = body(x, y)
2626
}
2727

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 {
2929
case '[String *: tpes] => '{ summon[Eq[String]] } :: summonAll[tpes]
3030
case '[Int *: tpes] => '{ summon[Eq[Int]] } :: summonAll[tpes]
3131
case '[tpe *: tpes] => derived[tpe] :: summonAll[tpes]

0 commit comments

Comments
 (0)