typetools / typetools/checker-framework
@BottomAll and @TopAll annotations
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.1k
- Forks
- 440
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 134
Description
Compiling this code with the Map Key Checker fails:
public abstract class Parent<T> {
public Parent(List<? super T> list) {}
}
public abstract class Child extends Parent<CharSequence> {
public Child(List<? super CharSequence> list) {
super(list);
}
}
because the unannotated T in ? super T is interpreted as having the annotation for the actual type argument, which is CharSequence in Parent<CharSequence>, which is defaulted to @UnknownKeyFor. The T in ? super T needs to have the bottom type for the type system.
The programmer could explicitly annotate it for each type system, but that could get wordy and tedious.
Instead, we should create @BottomAll and @TopAll annotations (analogously to @PolyAll). These annotations only have an effect if a type does not have an explicit annotation for the particular type system. For example, a programmer could write @PreppyCheckerWearsPoloShirt @HipsterCheckerWearsSkinnyJeans @BottomAll which means the bottom annotation in every type system except the preppy and hipster type systems.
The @BottomAll and @TopAll annotations are intended to be written on wildcard bounds and possibly in other places.
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 locating the existing @PolyAll annotation and the annotation definitions used by the Map Key Checker. Check how annotations on wildcard bounds are interpreted, then verify that @BottomAll and @TopAll provide defaults per type system while explicit annotations take precedence and the reported Parent/Child example compiles.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100