File tree 1 file changed +5
-4
lines changed
docs/docs/reference/metaprogramming 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -733,7 +733,7 @@ private def sumExpr(args1: Seq[Expr[Int]])(using Quotes): Expr[Int] = {
733
733
Sometimes it is necessary to get a more precise type for an expression. This can be achived using the following pattern match.
734
734
735
735
``` scala
736
- def f (exp : Expr [Any ])(using Quotes ) =
736
+ def f (expr : Expr [Any ])(using Quotes ) =
737
737
expr match
738
738
case ' { $x : t } =>
739
739
// 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
751
751
argsExpr match {
752
752
case Varargs (argExprs) =>
753
753
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 {
756
757
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); ' {??? }
758
759
}
759
760
}
760
761
val newArgsExpr = Varargs (argShowedExprs)
You can’t perform that action at this time.
0 commit comments