mirror of
https://github.com/apple/pkl.git
synced 2026-01-11 22:30:54 +01:00
codegen-java/kotlin: Support generating sealed classes #249
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @odenix on GitHub (Nov 12, 2024).
It would be very nice to generate sealed Java/Kotlin classes whenever possible. This would improve code comprehension, pattern matching, and the IDE experience.
Potential solutions:
At a minimum, this would require passing all Pkl modules at once to Java/KotlinCodeGenerator so that it can check if a class is subclassed in another module. Currently, Java/KotlinCodeGenerator only accepts a single module whereas CliJava/KotlinCodeGenerator accepts multiple.
@bioball commented on GitHub (Nov 13, 2024):
Without a
sealedin Pkl, there's no way to ensure that the provided set of classes is exhaustive. For example:@odenix commented on GitHub (Nov 13, 2024):
I think the conclusion is that moving forward with this feature would require a
sealedSPICE.@bioball commented on GitHub (Nov 13, 2024):
Yeah; I think that's right
@odenix commented on GitHub (Nov 15, 2024):
How about reserving the keyword
sealedfor now?@bioball commented on GitHub (Jan 24, 2025):
I'm okay with that!
@stackoverflow, @holzensp: thoughts?