From 59361856999e405105705d0c262483ccb7eb42e2 Mon Sep 17 00:00:00 2001 From: "Lan, Jian" Date: Sun, 29 Dec 2019 01:53:49 -0800 Subject: [PATCH 1/2] Update a link to Scala Language Specification from version 2.12 to version 2.13 --- docs/docs/reference/metaprogramming/inline.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/reference/metaprogramming/inline.md b/docs/docs/reference/metaprogramming/inline.md index 4c8dcdae6028..8fe64f9bd624 100644 --- a/docs/docs/reference/metaprogramming/inline.md +++ b/docs/docs/reference/metaprogramming/inline.md @@ -33,7 +33,7 @@ object Logger { The `Config` object contains a definition of the **inline value** `logging`. This means that `logging` is treated as a _constant value_, equivalent to its right-hand side `false`. The right-hand side of such an `inline val` must itself -be a [constant expression](https://scala-lang.org/files/archive/spec/2.12/06-expressions.html#constant-expressions). +be a [constant expression](https://scala-lang.org/files/archive/spec/2.13/06-expressions.html#constant-expressions). Used in this way, `inline` is equivalent to Java and Scala 2's `final`. Note that `final`, meaning _inlined constant_, is still supported in Dotty, but will be phased out. From 71c2e0dc78f4e1c1fdb7a4c7f67ac5fef1e954c9 Mon Sep 17 00:00:00 2001 From: "Lan, Jian" Date: Sun, 29 Dec 2019 02:01:45 -0800 Subject: [PATCH 2/2] Correct example code in the inline.md document --- docs/docs/reference/metaprogramming/inline.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/docs/reference/metaprogramming/inline.md b/docs/docs/reference/metaprogramming/inline.md index 8fe64f9bd624..b4861c0ccf82 100644 --- a/docs/docs/reference/metaprogramming/inline.md +++ b/docs/docs/reference/metaprogramming/inline.md @@ -108,16 +108,16 @@ inline def power(x: Double, n: Int): Double = { val y = power(x, n / 2) if (n % 2 == 0) y * y else y * y * x } - - power(expr, 10) - // translates to - // - // val x = expr - // val y1 = x * x // ^2 - // val y2 = y1 * y1 // ^4 - // val y3 = y2 * x // ^5 - // y3 * y3 // ^10 } + +power(expr, 10) +// translates to +// +// val x = expr +// val y1 = x * x // ^2 +// val y2 = y1 * y1 // ^4 +// val y3 = y2 * x // ^5 +// y3 * y3 // ^10 ``` Parameters of inline methods can have an `inline` modifier as well. This means