Skip to content

Commit 8c64e69

Browse files
committed
Some fixes to doc page
1 parent 69ee4d9 commit 8c64e69

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

docs/_docs/reference/experimental/erased-defs.md

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: "Erased Definitions"
44
nightlyOf: https://docs.scala-lang.org/scala3/reference/experimental/erased-defs.html
55
---
66

7-
`erased` is a modifier that expresses that some definition or expression is erased by the compiler instead of being represented in the compiled output. It is not yet part of the Scala language standard. To enable `erased`, turn on the language feature
7+
`erased` is a modifier that expresses that some value or parameter is erased by the compiler instead of being represented in the compiled output. It is not yet part of the Scala language standard. To enable `erased`, turn on the language feature
88
[`experimental.erasedDefinitions`](https://scala-lang.org/api/3.x/scala/runtime/stdLibPatches/language$$experimental$$erasedDefinitions$.html). This can be done with a language import
99
```scala
1010
import scala.language.experimental.erasedDefinitions
@@ -74,9 +74,9 @@ def methodWithErasedInt2(erased i: Int): Int =
7474
methodWithErasedInt1(i) // OK
7575
```
7676

77-
Not only parameters can be marked as erased, `val` and `def` can also be marked
78-
with `erased`. These will also only be usable as arguments to `erased`
79-
parameters.
77+
Besides parameters, `val` definitions can also be marked with `erased`.
78+
These will also only be usable as arguments to `erased` parameters or
79+
as part of the definitions of other erased `val`s.
8080

8181
```scala
8282
erased val erasedEvidence: Ev = ...
@@ -85,7 +85,7 @@ methodWithErasedEv(erasedEvidence, 40) // 42
8585

8686
## What happens with erased values at runtime?
8787

88-
As `erased` are guaranteed not to be used in computations, they can and will be
88+
As `erased` vals and parameters are guaranteed not to be used in computations, they can and will be
8989
erased.
9090

9191
```scala
@@ -130,7 +130,7 @@ class IsOff[S <: State]
130130
object IsOff:
131131
// will not be called at runtime for turnedOn, the
132132
// compiler will only require that this evidence exists
133-
given IsOff[Off] = new IsOff[Off]
133+
erased given IsOff[Off] = new IsOff[Off]
134134

135135
@implicitNotFound("State must be On")
136136
class IsOn[S <: State]
@@ -151,14 +151,7 @@ object Machine:
151151
val m = Machine.newMachine()
152152
m.turnedOn
153153
m.turnedOn.turnedOff
154-
155-
// m.turnedOff
156-
// ^
157-
// State must be On
158-
159-
// m.turnedOn.turnedOn
160-
// ^
161-
// State must be Off
154+
m.turnedOn.turnedOn // error: State must be Off
162155
```
163156

164157
Note that in [Compile-time operations](../metaprogramming/compiletime-ops.md#erasedvalue) we discussed `erasedValue` and inline

0 commit comments

Comments
 (0)