File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed
docs/docs/reference/enums Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -136,7 +136,6 @@ map into case classes or vals.
136
136
where ` n ` is the ordinal number of the case in the companion object,
137
137
starting from 0.
138
138
139
-
140
139
### Equality
141
140
142
141
An ` enum ` type contains a ` scala.Eq ` instance that restricts values of the ` enum ` type to
@@ -171,3 +170,20 @@ Companion objects that contain at least one simple case define in addition:
171
170
def toString = name
172
171
$values.register(this) // register enum value so that `valueOf` and `values` can return it.
173
172
}
173
+
174
+ ### Scopes for Enum Cases
175
+
176
+ A case in an ` enum ` is treated similarly to a secondary constructor. It cannot access
177
+ with simple identifiers value parameters or instance members of the enclosing ` enum ` .
178
+
179
+ Even though translated enum cases are located in the enum's companion object, they
180
+ cannot access with simple identifiers any members defined locally in the enclosing
181
+ object either. The compiler is free to typecheck enum cases in the scope of the
182
+ enclosing companion object but it must then flag any illegal accesses to the object's
183
+ members.
184
+
185
+ ### Other Rules
186
+
187
+ A normal case class which is not produced from an enum case is not allowed to extend
188
+ ` scala.Enum ` . This ensures that the only cases of an anum are the ones that are
189
+ explictly declared in it.
You can’t perform that action at this time.
0 commit comments