| 1 |
// The test cases GenericNull, FieldAccess, and InferTypeArgs often fail together. |
| 2 |
// Here are some things that might be wrong if they are failing. |
| 3 |
// * If you have overridden AnnotatedTypeFactory.createTreeAnnotator(), the body should return a |
| 4 |
// list that contains the result of running the overridden implementation, as in: |
| 5 |
// public TreeAnnotator createTreeAnnotator() { |
| 6 |
// return new ListTreeAnnotator(super.createTreeAnnotator(), new MyOwnTreeAnnotator(this)); |
| 7 |
// } |
| 8 |
// * If 'null' is intentionally not the bottom type in your type hierarchy, then you may suppress |
| 9 |
// this warning for your particular type system. |
| 10 |
// |
| 11 |
// * The standard defaulting rules set the qualifier of type variable lower |
| 12 |
// bounds to bottom. (https://checkerframework.org/manual/#climb-to-top) If |
| 13 |
// you change this default to top, then this error will go away. (Add the |
| 14 |
// meta-annotation @DefaultFor(LOWER_BOUNDS) to the top annotation class.) |
| 15 |
// This will make types like List<@Bottom Object> illegal, so carefully |
| 16 |
// consider if this is desirable. |
| 17 |
// |
| 18 |
|
| 19 |
class GenericNull { |
| 20 |
/** |
| 21 |
* In most type systems, null's type is bottom and therefore the generic return type T is a |
| 22 |
* supertype of null's type. |
| 23 |
* |
| 24 |
* <p>However, in the nullness and lock type systems, null's type is not bottom, so they exclude |
| 25 |
* this test. For the Lock Checker, null's type is bottom for the @GuardedByUnknown hierarchy |
| 26 |
* but not for the @LockPossiblyHeld hierarchy. |
| 27 |
*/ |
| 28 |
@SuppressWarnings({"nullness", "lock"}) |
| 29 |
<T> T f() { |
| 30 |
return null; |
| 31 |
} |
| 32 |
} |