typetools / checker-framework

Pluggable type-checking for Java
http://checkerframework.org/
Other
1.02k stars 354 forks source link

Create two versions of the Optional Checker #1425

Open mernst opened 7 years ago

mernst commented 7 years ago

One is a lightweight checker that is independent of the Nullness Checker. It only checks properties # 2-7, not anything about nullness. (I need to figure out all the places that the Optional Checker is coupled to the Nullness Checker. One example is the precise type-checking for the return type of ofNullable() is an example, but this probably isn't so important a feature: a user can use of() instead of ofNullable() if the user knows the arguments are non-null.)

The other is the Nullness Checker, which will do checking of Optional just as it currently does for Initialization and KeyFor. It makes sense to call this the Nullness Checker rather than the Optional Checker or the heavyweight Optional Checker, in terms of what most of the implementation is and in terms of getting people to use it (since the heavyweight Optional Checker wouldn't be as attractive as the Nullness Checker to a potential user). There are two possible implementation strategies.

mernst commented 6 years ago

Pull request https://github.com/typetools/checker-framework/pull/1361 has created the simple one. Integration with the Nullness Checker remains to be done.