Skip to content

Commit 48af933

Browse files
committed
Fix a code example showMeExpr in macros.md
- Fix a code example by copying its corresponding code from tests
1 parent 19a50bd commit 48af933

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

docs/docs/reference/metaprogramming/macros.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ private def sumExpr(args1: Seq[Expr[Int]])(using Quotes): Expr[Int] = {
733733
Sometimes it is necessary to get a more precise type for an expression. This can be achived using the following pattern match.
734734

735735
```scala
736-
def f(exp: Expr[Any])(using Quotes) =
736+
def f(expr: Expr[Any])(using Quotes) =
737737
expr match
738738
case '{ $x: t } =>
739739
// If the pattern match succeeds, then there is some type `t` such that
@@ -751,10 +751,11 @@ private def showMeExpr(sc: Expr[StringContext], argsExpr: Expr[Seq[Any]])(using
751751
argsExpr match {
752752
case Varargs(argExprs) =>
753753
val argShowedExprs = argExprs.map {
754-
case '{ $arg: t } =>
755-
Expr.summon[Show[t]] match {
754+
case '{ $arg: tp } =>
755+
val showTp = Type.of[Show[tp]]
756+
Expr.summon(using showTp) match {
756757
case Some(showExpr) => '{ $showExpr.show($arg) }
757-
case None => report.error(s"could not find implicit for ${showTp.show}", arg); '{???}
758+
case None => report.error(s"could not find implicit for ${Type.show[Show[tp]]}", arg); '{???}
758759
}
759760
}
760761
val newArgsExpr = Varargs(argShowedExprs)

0 commit comments

Comments
 (0)