Skip to content

Commit 5d004dc

Browse files
authored
Merge pull request #4527 from dotty-staging/constant-expr-clarify
Document meaning of constant expressions
2 parents 9f876b8 + eedc6be commit 5d004dc

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

docs/docs/reference/inline.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ inlined at the point of use. Example:
2929
The `Config` object contains a definition of an `inline` value
3030
`logging`. This means that `logging` is treated as a constant value,
3131
equivalent to its right-hand side `false`. The right-hand side of such
32-
an inline val must itself be a constant expression. Used in this way,
32+
an inline val must itself be a [constant
33+
expression](#the-definition-of-constant-expression). Used in this way,
3334
`inline` is equivalent to Java and Scala 2's `final`. `final` meaning
3435
"constant" is still supported in Dotty, but will be phased out.
3536

@@ -124,11 +125,15 @@ it in backticks, i.e.
124125

125126
@`inline` def ...
126127

128+
### The definition of constant expression
129+
130+
Right-hand sides of inline values and of arguments for inline parameters
131+
must be constant expressions in the sense defined by the [SLS §
132+
6.24](https://www.scala-lang.org/files/archive/spec/2.12/06-expressions.html#constant-expressions),
133+
including "platform-specific" extensions such as constant folding of
134+
pure numeric computations.
127135

128136
### Reference
129137

130138
For more info, see [PR #1492](https://github.com/lampepfl/dotty/pull/1492) and
131-
[Scala SIP 28](http://docs.scala-lang.org/sips/pending/inline-meta.html)
132-
133-
134-
139+
[Scala SIP 28](http://docs.scala-lang.org/sips/pending/inline-meta.html).

0 commit comments

Comments
 (0)