@@ -7,10 +7,17 @@ import annotation.compileTimeOnly
77 * pattern match on it. For example, given a type `Tup <: Tuple`, one can
88 * pattern-match on it as follows:
99 * ```scala
10+ * //{
11+ * type Tup
12+ * inline def f = {
13+ * //}
1014 * inline erasedValue[Tup] match {
11- * case _: EmptyTuple => ...
12- * case _: h *: t => ...
15+ * case _: EmptyTuple => ???
16+ * case _: ( h *: t) => ???
1317 * }
18+ * //{
19+ * }
20+ * //}
1421 * ```
1522 * This value can only be used in an inline match and the value cannot be used in
1623 * the branches.
@@ -21,7 +28,12 @@ def erasedValue[T]: T = ???
2128
2229/** Used as the initializer of a mutable class or object field, like this:
2330 *
24- * var x: T = uninitialized
31+ * ```scala
32+ * //{
33+ * type T
34+ * //}
35+ * var x: T = uninitialized
36+ * ```
2537 *
2638 * This signifies that the field is not initialized on its own. It is still initialized
2739 * as part of the bulk initialization of the object it belongs to, which assigns zero
@@ -33,7 +45,7 @@ def uninitialized: Nothing = ???
3345/** The error method is used to produce user-defined compile errors during inline expansion.
3446 * If an inline expansion results in a call error(msgStr) the compiler produces an error message containing the given msgStr.
3547 *
36- * ```scala
48+ * ```scala sc:fail
3749 * error("My error message")
3850 * ```
3951 * or
@@ -71,13 +83,13 @@ transparent inline def codeOf(arg: Any): String =
7183 * inlining and constant folding.
7284 *
7385 * Usage:
74- * ```scala
86+ * ```scala sc:fail
7587 * inline def twice(inline n: Int): Int =
7688 * requireConst(n) // compile-time assertion that the parameter `n` is a constant
7789 * n + n
7890 *
7991 * twice(1)
80- * val m: Int = ...
92+ * val m: Int = ???
8193 * twice(m) // error: expected a constant value but found: m
8294 * ```
8395 * @syntax markdown
@@ -116,14 +128,23 @@ end constValueTuple
116128/** Summons first given matching one of the listed cases. E.g. in
117129 *
118130 * ```scala
119- * given B { ... }
131+ * //{
132+ * type A
133+ * trait B
134+ * type C
135+ * inline def f = {
136+ * //}
137+ * given B with { }
120138 *
121139 * summonFrom {
122140 * case given A => 1
123141 * case given B => 2
124142 * case given C => 3
125143 * case _ => 4
126144 * }
145+ * //{
146+ * }
147+ * //}
127148 * ```
128149 * the returned value would be `2`.
129150 * @syntax markdown
0 commit comments