Skip to content

Commit 3039eca

Browse files
committed
Document meaning of constant expressions
Clarification following #4431. The error checking's done by `Checking.checkInlineConformant(tree, isFinal = false, "argument to inline parameter")`, and `checkInlineConformant` uses `ConstantType` which characterizes constant expressions.
1 parent 0a486e3 commit 3039eca

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

docs/docs/reference/inline.md

Lines changed: 9 additions & 1 deletion
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,6 +125,13 @@ 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

0 commit comments

Comments
 (0)