File tree 2 files changed +28
-1
lines changed
docs/docs/reference/metaprogramming
library/src-3.x/scala/compiletime
2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -383,12 +383,28 @@ The `error` method is used to produce user-defined compile errors during inline
383
383
It has the following signature:
384
384
385
385
``` scala
386
- inline def error (inline msg : String , objs : Any * ): Nothing
386
+ inline def error (inline msg : String ): Nothing
387
387
```
388
388
389
389
If an inline expansion results in a call ` error(msgStr) ` the compiler
390
390
produces an error message containing the given ` msgStr ` .
391
391
392
+ ``` scala
393
+ inline def fail () = {
394
+ error(" failed for a reason" )
395
+ }
396
+ fail() // error: failed for a reason
397
+ ```
398
+
399
+ or
400
+
401
+ ``` scala
402
+ inline def fail (p1 : => Any ) = {
403
+ error(code " failed on: $p1" )
404
+ }
405
+ fail(indentity(" foo" )) // error: failed on: indentity("foo")
406
+ ```
407
+
392
408
## Implicit Matches
393
409
394
410
It is foreseen that many areas of typelevel programming can be done with rewrite
Original file line number Diff line number Diff line change @@ -4,6 +4,17 @@ package object compiletime {
4
4
5
5
erased def erasedValue [T ]: T = ???
6
6
7
+ /** The error method is used to produce user-defined compile errors during inline expansion.
8
+ * If an inline expansion results in a call error(msgStr) the compiler produces an error message containing the given msgStr.
9
+ *
10
+ * ```scala
11
+ * error("My error message")
12
+ * ```
13
+ * or
14
+ * ```scala
15
+ * error(code"My error of this code: ${println("foo")}")
16
+ * ```
17
+ */
7
18
inline def error (inline msg : String ): Nothing = ???
8
19
9
20
/** Returns the string representations for code passed in the interpolated values
You can’t perform that action at this time.
0 commit comments