File tree Expand file tree Collapse file tree 2 files changed +10
-12
lines changed
docs/docs/reference/metaprogramming
tests/run-macros/string-context-implicits Expand file tree Collapse file tree 2 files changed +10
-12
lines changed Original file line number Diff line number Diff line change @@ -742,12 +742,12 @@ extension (inline sc: StringContext)
742742 inline def showMe (inline args : Any * ): String = $ { showMeExpr(' sc , ' args ) }
743743
744744private def showMeExpr (sc : Expr [StringContext ], argsExpr : Expr [Seq [Any ]])(using Quotes ): Expr [String ] =
745+ import quotes .reflect .report
745746 argsExpr match
746747 case Varargs (argExprs) =>
747748 val argShowedExprs = argExprs.map {
748749 case ' { $arg : tp } =>
749- val showTp = Type .of[Show [tp]]
750- Expr .summon(using showTp) match
750+ Expr .summon[Show [tp]] match
751751 case Some (showExpr) =>
752752 ' { $showExpr.show($arg) }
753753 case None =>
Original file line number Diff line number Diff line change @@ -3,26 +3,24 @@ import scala.quoted._
33
44extension (sc : StringContext ) inline def showMe (inline args : Any * ): String = $ { showMeExpr(' sc , ' args ) }
55
6- private def showMeExpr (sc : Expr [StringContext ], argsExpr : Expr [Seq [Any ]])(using Quotes ): Expr [String ] = {
6+ private def showMeExpr (sc : Expr [StringContext ], argsExpr : Expr [Seq [Any ]])(using Quotes ): Expr [String ] =
77 import quotes .reflect .report
8- argsExpr match {
8+ argsExpr match
99 case Varargs (argExprs) =>
1010 val argShowedExprs = argExprs.map {
1111 case ' { $arg : tp } =>
12- val showTp = Type .of [Show [tp]]
13- Expr .summon( using showTp) match {
14- case Some (showExpr) => ' { $showExpr.show($arg) }
15- case None => report.error( s " could not find implicit for ${ Type .show[ Show [tp]]} " , arg); ' { ??? }
16- }
12+ Expr .summon [Show [tp]] match
13+ case Some (showExpr) =>
14+ ' { $showExpr.show($arg) }
15+ case None =>
16+ report.error( s " could not find implicit for ${ Type .show[ Show [tp]]} " , arg); ' { ??? }
1717 }
1818 val newArgsExpr = Varargs (argShowedExprs)
1919 ' { $sc.s($newArgsExpr : _* ) }
2020 case _ =>
2121 // `new StringContext(...).showMeExpr(args: _*)` not an explicit `showMeExpr"..."`
2222 report.error(s " Args must be explicit " , argsExpr)
23- ' {??? }
24- }
25- }
23+ ' { ??? }
2624
2725trait Show [- T ] {
2826 def show (x : T ): String
You can’t perform that action at this time.
0 commit comments