Skip to content

jextract/jni: Skip discriminator generation if enum has no cases#573

Merged
ktoso merged 1 commit intoswiftlang:mainfrom
sidepelican:no_case_enum
Feb 27, 2026
Merged

jextract/jni: Skip discriminator generation if enum has no cases#573
ktoso merged 1 commit intoswiftlang:mainfrom
sidepelican:no_case_enum

Conversation

@sidepelican
Copy link
Contributor

Currently, when the Swift enum has no cases, the generated Java code results in a compilation error.

error: sealed class must have subclasses
  public sealed interface Case {}
                ^

In Swift, it is a common idiom to use enums with no cases as namespaces.

I have updated the generator to skip the generation of any case-related code when an enum contains no cases.

@sidepelican sidepelican requested a review from ktoso as a code owner February 25, 2026 07:27
Copy link
Collaborator

@ktoso ktoso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm, it may be better to emit but drop the "sealed" perhaps? Issues like "why didn't it get emitted" are annoying for users

@sidepelican
Copy link
Contributor Author

Looks good, having fewer differences might be preferable.
I'll reconsider the implementation in that direction.

@sidepelican sidepelican marked this pull request as draft February 27, 2026 07:57
@ktoso
Copy link
Collaborator

ktoso commented Feb 27, 2026

Thank you!

@sidepelican
Copy link
Contributor Author

New PR: #577

@ktoso
Copy link
Collaborator

ktoso commented Feb 27, 2026

#577 faced some complications, so let's accept this one actually, thank you!

@ktoso ktoso reopened this Feb 27, 2026
@ktoso ktoso marked this pull request as ready for review February 27, 2026 09:12
@ktoso ktoso merged commit 9cb0ba8 into swiftlang:main Feb 27, 2026
93 of 100 checks passed
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.

2 participants