Skip to content

Fix Expr.summon in docs #8535

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions docs/docs/reference/contextual/derivation-macro.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ implement a type class `derived` method using macros only. We follow the same
example of deriving `Eq` instances and for simplicity we support a `Product`
type e.g., a case class `Person`. The low-level method we will use to implement
the `derived` method exploits quotes, splices of both expressions and types and
the `scala.quoted.matching.summonExpr` method which is the equivalent of
the `scala.quoted.Expr.summon` method which is the equivalent of
`summonFrom`. The former is suitable for use in a quote context, used within
macros.

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

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

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

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

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

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

ev match {
case '{ $m: Mirror.ProductOf[T] { type MirroredElemTypes = $elementTypes }} =>
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/reference/metaprogramming/macros.md
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ private def showMeExpr(sc: Expr[StringContext], argsExpr: Expr[Seq[Any]])(using
val argShowedExprs = argExprs.map {
case '{ $arg: $tp } =>
val showTp = '[Show[$tp]]
summonExpr(using showTp)) match {
Expr.summon(using showTp) match {
case Some(showExpr) => '{ $showExpr.show($arg) }
case None => qctx.error(s"could not find implicit for ${showTp.show}", arg); '{???}
}
Expand Down