typetools / typetools/checker-framework
Feature of checking for pattern matching on case changing enums (discussion).
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.1k
- Forks
- 440
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 134
Description
One of the challenges of pattern matching enums is that not all enums are designed for exhaustive pattern matching.
I have written my own annotation that you put on an enum to indicate that you should not rely on exhaustive pattern matching:
https://jstach.io/doc/rainbowgum/current/apidocs/io.jstach.rainbowgum.annotation/io/jstach/rainbowgum/annotation/CaseChanging.html
The idea is to avoid the issue where version one we have
enum MyEnum {
A,
B
}
Consumer of library writes
MyEnum e;
switch(e) {
case A -> ...;
case B -> ...;
}
And then version 2 a mostly backward compatible version (lets ignore the debate what is a major, minor, etc semver policy and binary vs source compat):
enum MyEnum {
A,
B,
C
}
Then the client will get an unexpected failure for C.
Any way I was going to take a stab on implementing this checker on my own to try to improve my knowledge of the checkerframework and thought I would mention it.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the linked CaseChanging annotation and the Java enum examples in the issue. Investigate how the Checker Framework could represent and check this annotation for enum pattern matching; done requires an agreed checker design and defined behavior when a later enum version adds a constant.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100