You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/docs/reference/enums/desugarEnums.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -127,7 +127,6 @@ map into `case class`es or `val`s.
127
127
starting from 0. The anonymous class also
128
128
implements the abstract `Product` methods that it inherits from `Enum`.
129
129
130
-
131
130
It is an error if a value case refers to a type parameter of the enclosing `enum`
132
131
in a type argument of `<parents>`.
133
132
@@ -198,6 +197,7 @@ Even though translated enum cases are located in the enum's companion object, re
198
197
thisobjector its members via `this` or a simple identifier is also illegal. The compiler typechecks enumcases in the scope of the enclosing companion objectbut flags any such illegal accesses aserrors.
199
198
200
199
###Translation of Java-compatible enums
200
+
201
201
AJava-compatible enumis an enumthatextends`java.lang.Enum`. The translation rules are the same asabove, with the reservations defined in this section.
202
202
203
203
It is a compile-time error for a Java-compatible enumto have classcases.
@@ -206,9 +206,9 @@ Cases such as `case C` expand to a `@static val` as opposed to a `val`. This all
206
206
207
207
###OtherRules
208
208
209
-
-A normal caseclasswhich is not produced from an enumcase is not allowed to extend
210
-
`scala.reflect.Enum`. This ensures that the only cases of an enumare the ones that are
211
-
explicitly declared in it.
209
+
-A normal caseclasswhich is not produced from an enumcase is not allowed to extend
210
+
`scala.reflect.Enum`. This ensures that the only cases of an enumare the ones that are
211
+
explicitly declared in it.
212
212
213
-
-If an enumcase has an `extends` clause, the enumclass must be one of the
214
-
classes that's extended.
213
+
-If an enumcase has an `extends` clause, the enumclass must be one of the
Copy file name to clipboardExpand all lines: docs/docs/reference/enums/enums.md
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -93,6 +93,7 @@ end Planet
93
93
As a library author, you may want to signal that an enum case is no longer intended for use. However you could still want to gracefully handle the removal of a case from your public API, such as special casing deprecated cases.
94
94
95
95
To illustrate, say that the `Planet` enum originally had an additional case:
96
+
96
97
```diff
97
98
enum Planet(mass: Double, radius: Double):
98
99
...
@@ -128,9 +129,11 @@ object Planet {
128
129
}
129
130
}
130
131
```
132
+
131
133
We could imagine that a library may use [type class derivation](../contextual/derivation.md) to automatically provide an instance for `Deprecations`.
132
134
133
135
### Compatibility with Java Enums
136
+
134
137
If you want to use the Scala-defined enums as [Java enums](https://docs.oracle.com/javase/tutorial/java/javaOO/enum.html), you can do so by extending
135
138
the class `java.lang.Enum`, which is imported by default, as follows:
0 commit comments