@@ -28,6 +28,11 @@ package object compiletime {
28
28
* ```scala
29
29
* error(code"My error of this code: ${println("foo")}")
30
30
* ```
31
+ * or
32
+ * ```scala
33
+ * inline def errorOnThisCode(inline x: Any) =
34
+ * error(code"My error of this code: $x")
35
+ * ```
31
36
*/
32
37
inline def error (inline msg : String ): Nothing = ???
33
38
@@ -50,7 +55,9 @@ package object compiletime {
50
55
* @note only `inline` arguments will be displayed as "code".
51
56
* Other values may display unintutively.
52
57
*/
53
- transparent inline def code (inline args : Any * ): String = ???
58
+ transparent inline def code (inline args : Any * ): String =
59
+ // implemented in dotty.tools.dotc.typer.Inliner.Intrinsics
60
+ error(" `code` was not evaluated by the compiler" )
54
61
55
62
end extension
56
63
@@ -68,18 +75,24 @@ package object compiletime {
68
75
* twice(m) // error: expected a constant value but found: m
69
76
* ```
70
77
*/
71
- inline def requireConst (inline x : Boolean | Byte | Short | Int | Long | Float | Double | Char | String ): Unit = ()
78
+ inline def requireConst (inline x : Boolean | Byte | Short | Int | Long | Float | Double | Char | String ): Unit =
79
+ // implemented in dotty.tools.dotc.typer.Inliner
80
+ error(" `requireConst` was not evaluated by the compiler" )
72
81
73
82
/** Same as `constValue` but returns a `None` if a constant value
74
83
* cannot be constructed from the provided type. Otherwise returns
75
84
* that value wrapped in `Some`.
76
85
*/
77
- inline def constValueOpt [T ]: Option [T ] = ???
86
+ inline def constValueOpt [T ]: Option [T ] =
87
+ // implemented in dotty.tools.dotc.typer.Inliner
88
+ error(" `constValueOpt` was not evaluated by the compiler" )
78
89
79
90
/** Given a constant, singleton type `T`, convert it to a value
80
91
* of the same singleton type. For example: `assert(constValue[1] == 1)`.
81
92
*/
82
- inline def constValue [T ]: T = ???
93
+ inline def constValue [T ]: T =
94
+ // implemented in dotty.tools.dotc.typer.Inliner
95
+ error(" `constValue` was not evaluated by the compiler" )
83
96
84
97
/** Given a tuple type `(X1, ..., Xn)`, returns a tuple value
85
98
* `(constValue[X1], ..., constValue[Xn])`.
@@ -106,8 +119,8 @@ package object compiletime {
106
119
*
107
120
* the returned value would be `2`.
108
121
*/
109
- transparent inline def summonFrom [T ](f : Nothing => T ): T = ???
110
-
122
+ transparent inline def summonFrom [T ](f : Nothing => T ): T =
123
+ error( " `summonFrom` was not evaluated by the compiler " )
111
124
112
125
/** Summon a given value of type `T`. Usually, the argument is not passed explicitly.
113
126
* The summoning is delayed until the call has been fully inlined.
0 commit comments