Skip to content

Commit ea27651

Browse files
authored
Merge pull request #8535 from dotty-staging/update-macro-docs-2
Fix Expr.summon in docs
2 parents b64b8a9 + f1f63d5 commit ea27651

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ implement a type class `derived` method using macros only. We follow the same
99
example of deriving `Eq` instances and for simplicity we support a `Product`
1010
type e.g., a case class `Person`. The low-level method we will use to implement
1111
the `derived` method exploits quotes, splices of both expressions and types and
12-
the `scala.quoted.matching.summonExpr` method which is the equivalent of
12+
the `scala.quoted.Expr.summon` method which is the equivalent of
1313
`summonFrom`. The former is suitable for use in a quote context, used within
1414
macros.
1515

@@ -44,7 +44,7 @@ from the signature. The body of the `derived` method is shown below:
4444
given derived[T: Type](using qctx: QuoteContext) as Expr[Eq[T]] = {
4545
import qctx.tasty._
4646

47-
val ev: Expr[Mirror.Of[T]] = summonExpr(using '[Mirror.Of[T]]).get
47+
val ev: Expr[Mirror.Of[T]] = Expr.summon(using '[Mirror.Of[T]]).get
4848

4949
ev match {
5050
case '{ $m: Mirror.ProductOf[T] { type MirroredElemTypes = $elementTypes }} =>
@@ -70,7 +70,7 @@ given derived[T: Type](using qctx: QuoteContext) as Expr[Eq[T]] = {
7070

7171
Note, that in the `inline` case we can merely write
7272
`summonAll[m.MirroredElemTypes]` inside the inline method but here, since
73-
`summonExpr` is required, we can extract the element types in a macro fashion.
73+
`Expr.summon` is required, we can extract the element types in a macro fashion.
7474
Being inside a macro, our first reaction would be to write the code below. Since
7575
the path inside the type argument is not stable this cannot be used:
7676

@@ -178,7 +178,7 @@ object Eq {
178178
given derived[T: Type](using qctx: QuoteContext) as Expr[Eq[T]] = {
179179
import qctx.tasty._
180180

181-
val ev: Expr[Mirror.Of[T]] = summonExpr(using '[Mirror.Of[T]]).get
181+
val ev: Expr[Mirror.Of[T]] = Expr.summon(using '[Mirror.Of[T]]).get
182182

183183
ev match {
184184
case '{ $m: Mirror.ProductOf[T] { type MirroredElemTypes = $elementTypes }} =>

docs/docs/reference/metaprogramming/macros.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ private def showMeExpr(sc: Expr[StringContext], argsExpr: Expr[Seq[Any]])(using
725725
val argShowedExprs = argExprs.map {
726726
case '{ $arg: $tp } =>
727727
val showTp = '[Show[$tp]]
728-
summonExpr(using showTp)) match {
728+
Expr.summon(using showTp) match {
729729
case Some(showExpr) => '{ $showExpr.show($arg) }
730730
case None => qctx.error(s"could not find implicit for ${showTp.show}", arg); '{???}
731731
}

0 commit comments

Comments
 (0)