Skip to content
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

fix: Remove super calls from implicit enum constructors #4769

Merged
merged 1 commit into from
Jul 7, 2022

Conversation

I-Al-Istannen
Copy link
Collaborator

@I-Al-Istannen I-Al-Istannen commented Jun 27, 2022

The context

This aims to fix #4758 by removing the super call from implicit enum constructors.

The problem

For some reason JDT inserts a super() call in implicit enum constructors. This is likely because the model spoon transforms is not low-level enough and traversed before JDT converts it into a String, int constructor. Explicit super calls are forbidden as java.lang.Enum subclasses are permitted to delegate to the Enum constructor in whatever way they like.

The constructor is implicit so this isn't technically illegal, but it doesn't really make much sense as explicit constructors can never contain such a call. Additionally, the Enum class from the standard library has a "String, int" constructor, rendering the parameterless supercall semantically invalid.

The proposed fix

We just remove the call to make it a bit more consistent.

@MartinWitt
Copy link
Collaborator

LGTM will merge. It's always fascinating how much attention you pay to small details like this.

@MartinWitt MartinWitt changed the title review: fix: Remove super calls from implicit enum constructors fix: Remove super calls from implicit enum constructors Jul 7, 2022
@MartinWitt MartinWitt merged commit 3381d4a into INRIA:master Jul 7, 2022
@I-Al-Istannen I-Al-Istannen deleted the fix/4758 branch July 7, 2022 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Spoon representation does not model the implicit String and int parameters to enum constructors
2 participants