[nullsafe] Add `nullsafe_FIXME` method to suppress nullability issues.

Summary:
This will help adoption of non-transitive strictification modes.
The main use-case we are aiming with this function is:
- During strictification, a method is made nullable, but it is not feasible to fix all
callers straight away. Suppressing nullsafe with an appropriate task or
comment will make it easier to unblock the strictification and move
forward.

Reviewed By: artempyanykh

Differential Revision: D19599098

fbshipit-source-id: 3769bbd3d
master
Mitya Lyubarskiy 5 years ago committed by Facebook Github Bot
parent 964a11ae23
commit 8199ed1555

@ -54,6 +54,15 @@ public class Assertions {
return object;
}
/**
* Makes Nullsafe stop complaining when {@code object} is dereferenced or converted to a
* non-nullable. In contrast with {@link #assumeNotNull()}, indicates cases when the proper fix
* needs to be committed, but for some reason it is hard or impossible to do it staight away.
*/
public static <T> T nullsafeFIXME(@Nullable T object, String explanationOrTask) {
return object;
}
public static <T> T assertGet(int index, List<T> list) {
assertCondition(0 <= index && index < list.size(), "Index not in bound");
return assertNotNull(list.get(index), "Null value");

@ -140,6 +140,10 @@ let check_not_null_parameter_list, check_not_null_list =
, (o, [n; o])
, "com.facebook.infer.annotation.Assertions.assumeNotNull(java.lang.Object,java.lang.String):java.lang.Object"
)
; ( 1
, (o, [n; o])
, "com.facebook.infer.annotation.Assertions.nullsafeFIXME(java.lang.Object,java.lang.String):java.lang.Object"
)
; ( 1
, (o, [n])
, "androidx.core.util.Preconditions.checkNotNull(java.lang.Object):java.lang.Object" )

Loading…
Cancel
Save