-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Should we remove scala.Enum trait as a parent of enums? #9873
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
alternatively it is possible to special case some specific desugarings to occur after parents are known |
I think this is a problem. Could we have a way to provide the label to the Mirror framework without relying on
Yes but |
This one is fine because the code that is already generated checks for the enum flag, and knows the concrete class so this is just an extra case. Looking at the tests again, it appears it is possible that given a
This should be fine as we've removed other things, like when we changed the package of |
…nums this commit introduces the concept that some desugaring expansion can occur after parents of the current class are known, i.e. methods that contain no references like ordinal and enumLabel.
…nums this commit introduces the concept that some desugaring expansion can occur after parents of the current class are known, i.e. methods that contain no references like ordinal and enumLabel.
scala.reflect.Enum is now a universal super trait. Also avoid using derivesFrom(defn.EnumClass) and instead look for enum flag.
scala.reflect.Enum is now a universal super trait. Also avoid using derivesFrom(defn.EnumClass) and instead look for enum flag.
scala.reflect.Enum is now a universal super trait. Also avoid using derivesFrom(defn.EnumClass) and instead look for enum flag.
Spec given: We will rename scala.Enum to scala.reflect.Enum instead, and make it a super trait |
fix #9873: move scala.Enum to scala.reflect.Enum
Uh oh!
There was an error while loading. Please reload this page.
This issue poses the question of do we remove this trait, but keep the same API for individual enum classes, e.g. the following would still work after the change:
Minimized example
Output
Points in Favour
java.lang.Enum
Points Against
abstract class Colour
if it derives fromjava.lang.Enum
(Edit: alternatively it is possible to special case some specific desugarings to occur after parents are known)def ordinal: Int
when the parent isjava.lang.Enum
, leading to override errorsenumLabel
scala.Enum
could be renamed (and remain a parent) so thatjava.lang.Enum
parent does not need to be fully qualifiedConsiderations
ordinal
method should be renamed to avoid clashes withjava.lang.Enum
ordinal
instance method and advise to use theordinal
method on the companion object. (same forenumLabel
?)Mirror.Sum
cc @odersky @smarter @sjrd
The text was updated successfully, but these errors were encountered: