File tree 4 files changed +36
-0
lines changed 4 files changed +36
-0
lines changed Original file line number Diff line number Diff line change 1
1
package scala .quoted
2
2
3
3
import scala .annotation .experimental
4
+ import scala .annotation .implicitNotFound
4
5
import scala .reflect .TypeTest
5
6
6
7
/** Current Quotes in scope
@@ -21,7 +22,25 @@ transparent inline def quotes(using q: Quotes): q.type = q
21
22
*
22
23
* It contains the low-level Typed AST API metaprogramming API.
23
24
* 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
+ * ```
24
35
*/
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
+ """ )
25
44
trait Quotes { self : runtime.QuoteUnpickler & runtime.QuoteMatching =>
26
45
27
46
// 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 2
2
5 | case '{ StringContext(${Varargs(parts)}*) } => // error
3
3
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4
4
| No given instance of type scala.quoted.Quotes was found
5
+ |
6
+ | longer explanation available when compiling with `-explain`
5
7
-- [E006] Not Found Error: tests/neg-macros/i6436.scala:6:34 -----------------------------------------------------------
6
8
6 | val ps: Seq[Expr[String]] = parts // error
7
9
| ^^^^^
You can’t perform that action at this time.
0 commit comments