File tree Expand file tree Collapse file tree 4 files changed +36
-0
lines changed Expand file tree Collapse file tree 4 files changed +36
-0
lines changed Original file line number Diff line number Diff line change 11package scala .quoted
22
33import scala .annotation .experimental
4+ import scala .annotation .implicitNotFound
45import scala .reflect .TypeTest
56
67/** Current Quotes in scope
@@ -21,7 +22,25 @@ transparent inline def quotes(using q: Quotes): q.type = q
2122 *
2223 * It contains the low-level Typed AST API metaprogramming API.
2324 * This API does not have the static type guarantees that `Expr` and `Type` provide.
25+ * `Quotes` are generated from an enclosing `${ ... }` or `scala.staging.run`. For example:
26+ * ```scala sc:nocompile
27+ * import scala.quoted._
28+ * inline def myMacro: Expr[T] =
29+ * ${ /* (quotes: Quotes) ?=> */ myExpr }
30+ * def myExpr(using Quotes): Expr[T] =
31+ * '{ f(${ /* (quotes: Quotes) ?=> */ myOtherExpr }) }
32+ * }
33+ * def myOtherExpr(using Quotes): Expr[U] = '{ ... }
34+ * ```
2435 */
36+
37+ @ implicitNotFound(""" explain=Maybe this methods is missing a `(using Quotes)` parameter.
38+
39+ Maybe that splice `$ { ... }` is missing?
40+ Given instances of `Quotes` are generated from an enclosing splice `$ { ... }` (or `scala.staging.run` call).
41+ A splice can be thought as a method with the following signature.
42+ def $[T](body: Quotes ?=> Expr[T]): T
43+ """ )
2544trait Quotes { self : runtime.QuoteUnpickler & runtime.QuoteMatching =>
2645
2746 // Extension methods for `Expr[T]`
Original file line number Diff line number Diff line change 1+ -- [E172] Type Error: tests/neg-custom-args/explain/i16888.scala:1:38 --------------------------------------------------
2+ 1 |def test = summon[scala.quoted.Quotes] // error
3+ | ^
4+ | No given instance of type quoted.Quotes was found for parameter x of method summon in object Predef
5+ |---------------------------------------------------------------------------------------------------------------------
6+ | Explanation (enabled by `-explain`)
7+ |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
8+ | Maybe this methods is missing a `(using Quotes)` parameter.
9+ |
10+ | Maybe that splice `$ { ... }` is missing?
11+ | Given instances of `Quotes` are generated from an enclosing splice `$ { ... }` (or `scala.staging.run` call).
12+ | A splice can be thought as a method with the following signature.
13+ | def $[T](body: Quotes ?=> Expr[T]): T
14+ ---------------------------------------------------------------------------------------------------------------------
Original file line number Diff line number Diff line change 1+ def test = summon[scala.quoted.Quotes ] // error
Original file line number Diff line number Diff line change 225 | case '{ StringContext(${Varargs(parts)}*) } => // error
33 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
44 | No given instance of type scala.quoted.Quotes was found
5+ |
6+ | longer explanation available when compiling with `-explain`
57-- [E006] Not Found Error: tests/neg-macros/i6436.scala:6:34 -----------------------------------------------------------
686 | val ps: Seq[Expr[String]] = parts // error
79 | ^^^^^
You can’t perform that action at this time.
0 commit comments