Skip to content

Commit 22322a0

Browse files
committed
Make summonExpr simpler to use with explicit args
1 parent 039452f commit 22322a0

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

docs/docs/reference/metaprogramming/macros.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ private def showMeExpr(sc: Expr[StringContext], argsExpr: Expr[Seq[Any]])(given
712712
val argShowedExprs = argExprs.map {
713713
case '{ $arg: $tp } =>
714714
val showTp = '[Show[$tp]]
715-
summonExpr(given showTp), summon[QuoteContext]) match {
715+
summonExpr(given showTp)) match {
716716
case Some(showExpr) => '{ $showExpr.show($arg) }
717717
case None => qctx.error(s"could not find implicit for ${showTp.show}", arg); '{???}
718718
}

library/src/scala/quoted/matching/package.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ package object matching {
1010
* @param tpe quoted type of the implicit parameter
1111
* @param qctx current context
1212
*/
13-
def summonExpr[T](given tpe: Type[T], qctx: QuoteContext): Option[Expr[T]] = {
13+
def summonExpr[T](given tpe: Type[T])(given qctx: QuoteContext): Option[Expr[T]] = {
1414
import qctx.tasty.{_, given}
1515
searchImplicit(tpe.unseal.tpe) match {
1616
case iss: ImplicitSearchSuccess => Some(iss.tree.seal.asInstanceOf[Expr[T]])

tests/run-macros/string-context-implicits/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ private def showMeExpr(sc: Expr[StringContext], argsExpr: Expr[Seq[Any]])(given
99
val argShowedExprs = argExprs.map {
1010
case '{ $arg: $tp } =>
1111
val showTp = '[Show[$tp]]
12-
summonExpr(given showTp, summon[QuoteContext]) match {
12+
summonExpr(given showTp) match {
1313
case Some(showExpr) => '{ $showExpr.show($arg) }
1414
case None => qctx.error(s"could not find implicit for ${showTp.show}", arg); '{???}
1515
}

0 commit comments

Comments
 (0)