@@ -7,10 +7,17 @@ import annotation.compileTimeOnly
7
7
* pattern match on it. For example, given a type `Tup <: Tuple`, one can
8
8
* pattern-match on it as follows:
9
9
* ```scala
10
+ * //{
11
+ * type Tup
12
+ * inline def f = {
13
+ * //}
10
14
* inline erasedValue[Tup] match {
11
- * case _: EmptyTuple => ...
12
- * case _: h *: t => ...
15
+ * case _: EmptyTuple => ???
16
+ * case _: ( h *: t) => ???
13
17
* }
18
+ * //{
19
+ * }
20
+ * //}
14
21
* ```
15
22
* This value can only be used in an inline match and the value cannot be used in
16
23
* the branches.
@@ -21,7 +28,12 @@ def erasedValue[T]: T = ???
21
28
22
29
/** Used as the initializer of a mutable class or object field, like this:
23
30
*
24
- * var x: T = uninitialized
31
+ * ```scala
32
+ * //{
33
+ * type T
34
+ * //}
35
+ * var x: T = uninitialized
36
+ * ```
25
37
*
26
38
* This signifies that the field is not initialized on its own. It is still initialized
27
39
* as part of the bulk initialization of the object it belongs to, which assigns zero
@@ -33,7 +45,7 @@ def uninitialized: Nothing = ???
33
45
/** The error method is used to produce user-defined compile errors during inline expansion.
34
46
* If an inline expansion results in a call error(msgStr) the compiler produces an error message containing the given msgStr.
35
47
*
36
- * ```scala
48
+ * ```scala sc:fail
37
49
* error("My error message")
38
50
* ```
39
51
* or
@@ -71,13 +83,13 @@ transparent inline def codeOf(arg: Any): String =
71
83
* inlining and constant folding.
72
84
*
73
85
* Usage:
74
- * ```scala
86
+ * ```scala sc:fail
75
87
* inline def twice(inline n: Int): Int =
76
88
* requireConst(n) // compile-time assertion that the parameter `n` is a constant
77
89
* n + n
78
90
*
79
91
* twice(1)
80
- * val m: Int = ...
92
+ * val m: Int = ???
81
93
* twice(m) // error: expected a constant value but found: m
82
94
* ```
83
95
* @syntax markdown
@@ -116,14 +128,23 @@ end constValueTuple
116
128
/** Summons first given matching one of the listed cases. E.g. in
117
129
*
118
130
* ```scala
119
- * given B { ... }
131
+ * //{
132
+ * type A
133
+ * trait B
134
+ * type C
135
+ * inline def f = {
136
+ * //}
137
+ * given B with { }
120
138
*
121
139
* summonFrom {
122
140
* case given A => 1
123
141
* case given B => 2
124
142
* case given C => 3
125
143
* case _ => 4
126
144
* }
145
+ * //{
146
+ * }
147
+ * //}
127
148
* ```
128
149
* the returned value would be `2`.
129
150
* @syntax markdown
0 commit comments