Skip to content

Commit 70b2f38

Browse files
committed
Add decsription of Eq desugarings for enums
1 parent 961b9ef commit 70b2f38

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

docs/docs/reference/desugarEnums.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,15 @@ comma separated simple cases into a sequence of cases.
138138
Any modifiers or annotations on the original case extend to all expanded
139139
cases.
140140

141+
## Equality
142+
143+
An `enum` type contains a `scala.Eq` instance that restricts values of the `enum` type to
144+
be compared only to other values of the same enum type. Furtermore, generic
145+
`enum` types are comparable only if their type arguments are. For instance the
146+
`Option` enum type will get the following definition in its companion object:
147+
148+
implicit def eqOption[T, U](implicit ev1: Eq[T, U]): Eq[Option[T], Option[U]] = Eq
149+
141150
## Translation of Enumerations
142151

143152
Non-generic enum classes `E` that define one or more singleton cases

0 commit comments

Comments
 (0)