@@ -29,24 +29,26 @@ package object compiletime {
2929 */
3030 inline def error (inline msg : String ): Nothing = ???
3131
32- /** Returns the string representation of interpolated elaborated code:
33- *
34- * ```scala
35- * inline def logged(p1: => Any) = {
36- * val c = code"code: $p1"
37- * val res = p1
38- * (c, p1)
39- * }
40- * logged(identity("foo"))
41- * // above is equivalent to:
42- * // ("code: scala.Predef.identity("foo")", identity("foo"))
43- * ```
44- *
45- * @note only by-name arguments will be displayed as "code".
46- * Other values may display unintutively.
47- */
48- transparent inline def (inline self : StringContext ) code (inline args : Any * ): String =
49- $ { dotty.internal.CompileTimeMacros .codeExpr(' self , ' args ) }
32+ extension (inline self : StringContext ):
33+ /** Returns the string representation of interpolated elaborated code:
34+ *
35+ * ```scala
36+ * inline def logged(p1: => Any) = {
37+ * val c = code"code: $p1"
38+ * val res = p1
39+ * (c, p1)
40+ * }
41+ * logged(identity("foo"))
42+ * // above is equivalent to:
43+ * // ("code: scala.Predef.identity("foo")", identity("foo"))
44+ * ```
45+ *
46+ * @note only by-name arguments will be displayed as "code".
47+ * Other values may display unintutively.
48+ */
49+ transparent inline def code (inline args : Any * ): String =
50+ $ { dotty.internal.CompileTimeMacros .codeExpr(' self , ' args ) }
51+ end extension
5052
5153 /** Same as `constValue` but returns a `None` if a constant value
5254 * cannot be constructed from the provided type. Otherwise returns
0 commit comments