lampepfl / dotty-feature-requests

Historical feature requests. Please create new feature requests at https://github.com/lampepfl/dotty/discussions/new?category=feature-requests
31 stars 2 forks source link

use $new for singleton enums with extends clause (and no mixins) #255

Closed bishabosha closed 1 year ago

bishabosha commented 3 years ago

for the cases of singleton enum values where the enum definition has parameters, it would make sense to add those parameters to the $new creator method. This would make the Planets example require only three classes, (Planet, Planet$, and one anon class for the implementation) and not one class for each planet.

This can not be extended to cases that mixin other traits, these will still need individual anonymous classes.

bishabosha commented 3 years ago

previously, as soon as a singleton enum case requires to pass parameters to its parent, an anonymous class is generated for the case - which seems unnecessary when there is no variance except for passed parameters