codegen-java/kotlin: Support generating sealed classes
- Dominant language
- Java
- Stars
- 11.5k
- Forks
- 402
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 20
Description
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:
1. Infer which abstract and open Pkl classes can be sealed in Java/Kotlin.
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.
2. Support sealed classes in Pkl. This feels like a cleaner solution and could prove equally useful as supporting open vs. non-open classes.
Contributor guide
Research direction
Start with Java/KotlinCodeGenerator and CliJava/KotlinCodeGenerator, comparing their single-module and multi-module inputs. Determine whether sealedness should be inferred during generation or supported in Pkl itself; done requires an agreed approach and sealed classes generated correctly for eligible hierarchies.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, kotlin
- Domain
- compilers, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100