@@ -28,6 +28,11 @@ package object compiletime {
2828 * ```scala
2929 * error(code"My error of this code: ${println("foo")}")
3030 * ```
31+ * or
32+ * ```scala
33+ * inline def errorOnThisCode(inline x: Any) =
34+ * error(code"My error of this code: $x")
35+ * ```
3136 */
3237 inline def error (inline msg : String ): Nothing = ???
3338
@@ -50,7 +55,9 @@ package object compiletime {
5055 * @note only `inline` arguments will be displayed as "code".
5156 * Other values may display unintutively.
5257 */
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" )
5461
5562 end extension
5663
@@ -68,18 +75,24 @@ package object compiletime {
6875 * twice(m) // error: expected a constant value but found: m
6976 * ```
7077 */
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" )
7281
7382 /** Same as `constValue` but returns a `None` if a constant value
7483 * cannot be constructed from the provided type. Otherwise returns
7584 * that value wrapped in `Some`.
7685 */
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" )
7889
7990 /** Given a constant, singleton type `T`, convert it to a value
8091 * of the same singleton type. For example: `assert(constValue[1] == 1)`.
8192 */
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" )
8396
8497 /** Given a tuple type `(X1, ..., Xn)`, returns a tuple value
8598 * `(constValue[X1], ..., constValue[Xn])`.
@@ -106,8 +119,8 @@ package object compiletime {
106119 *
107120 * the returned value would be `2`.
108121 */
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 " )
111124
112125 /** Summon a given value of type `T`. Usually, the argument is not passed explicitly.
113126 * The summoning is delayed until the call has been fully inlined.
0 commit comments