Skip to content

Prevent extending java.lang.Enum except from an enum #7499

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

Closed
bishabosha opened this issue Nov 5, 2019 · 1 comment · Fixed by #9487
Closed

Prevent extending java.lang.Enum except from an enum #7499

bishabosha opened this issue Nov 5, 2019 · 1 comment · Fixed by #9487

Comments

@bishabosha
Copy link
Member

bishabosha commented Nov 5, 2019

as detailed in lampepfl/dotty-feature-requests#73, extending java.lang.Enum from a class is forbidden in Java, as Java enums are only guaranteed typesafe when created from its enum construct, additionally, the super call to java/lang/Enum."<init>":(Ljava/lang/String;I)V is synthesised by javac and the constructor is not exposed to Java source programs.

We should do the same in Dotty - extending java.lang.Enum should not be permitted apart from in an enum.

We should also support the old scala 2 way of extending java.lang.Enum with 3.0-migration

@ekrich
Copy link
Contributor

ekrich commented Nov 7, 2019

Linking for reference - #7174

TheElectronWill added a commit to TheElectronWill/dotty that referenced this issue Aug 3, 2020
TheElectronWill added a commit to TheElectronWill/dotty that referenced this issue Aug 3, 2020
TheElectronWill added a commit to TheElectronWill/dotty that referenced this issue Aug 7, 2020
TheElectronWill added a commit that referenced this issue Aug 7, 2020
Fix #7499: Prevent extending java.lang.Enum except from an enum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants