@@ -88,16 +88,14 @@ object DesugarEnums {
88
88
def enumDefDef (name : String , select : String ) =
89
89
DefDef (name.toTermName, Nil , Nil , TypeTree (), valuesDot(select))
90
90
91
- if (enumClass.exists) {
92
- val privateValuesDef =
93
- ValDef (nme.DOLLAR_VALUES , TypeTree (),
94
- New (TypeTree (defn.EnumValuesType .appliedTo(enumClass.typeRef :: Nil )), ListOfNil ))
95
- .withFlags(Private )
96
- val valueOfDef = enumDefDef(" enumValue" , " fromInt" )
97
- val withNameDef = enumDefDef(" enumValueNamed" , " fromName" )
98
- val valuesDef = enumDefDef(" enumValues" , " values" )
99
- List (privateValuesDef, valueOfDef, withNameDef, valuesDef)
100
- } else List .empty
91
+ val privateValuesDef =
92
+ ValDef (nme.DOLLAR_VALUES , TypeTree (),
93
+ New (TypeTree (defn.EnumValuesType .appliedTo(enumClass.typeRef :: Nil )), ListOfNil ))
94
+ .withFlags(Private )
95
+ val valueOfDef = enumDefDef(" enumValue" , " fromInt" )
96
+ val withNameDef = enumDefDef(" enumValueNamed" , " fromName" )
97
+ val valuesDef = enumDefDef(" enumValues" , " values" )
98
+ List (privateValuesDef, valueOfDef, withNameDef, valuesDef)
101
99
}
102
100
103
101
/** A creation method for a value of enum type `E`, which is defined as follows:
@@ -198,7 +196,8 @@ object DesugarEnums {
198
196
/** Expand a module definition representing a parameterless enum case */
199
197
def expandEnumModule (name : TermName , impl : Template , mods : Modifiers , pos : Position )(implicit ctx : Context ): Tree = {
200
198
assert(impl.body.isEmpty)
201
- if (impl.parents.isEmpty)
199
+ if (! enumClass.exists) EmptyTree
200
+ else if (impl.parents.isEmpty)
202
201
expandSimpleEnumCase(name, mods, pos)
203
202
else {
204
203
def toStringMeth =
@@ -213,8 +212,7 @@ object DesugarEnums {
213
212
214
213
/** Expand a simple enum case */
215
214
def expandSimpleEnumCase (name : TermName , mods : Modifiers , pos : Position )(implicit ctx : Context ): Tree =
216
- if (! enumClass.exists) EmptyTree
217
- else if (enumClass.typeParams.nonEmpty) {
215
+ if (enumClass.typeParams.nonEmpty) {
218
216
val parent = interpolatedEnumParent(pos)
219
217
val impl = Template (emptyConstructor, parent :: Nil , EmptyValDef , Nil )
220
218
expandEnumModule(name, impl, mods, pos)
0 commit comments