diff --git a/infer/annotations/src/main/java/com/facebook/infer/annotation/Assertions.java b/infer/annotations/src/main/java/com/facebook/infer/annotation/Assertions.java index faf4ac728..764c21bab 100644 --- a/infer/annotations/src/main/java/com/facebook/infer/annotation/Assertions.java +++ b/infer/annotations/src/main/java/com/facebook/infer/annotation/Assertions.java @@ -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 nullsafeFIXME(@Nullable T object, String explanationOrTask) { + return object; + } + public static T assertGet(int index, List list) { assertCondition(0 <= index && index < list.size(), "Index not in bound"); return assertNotNull(list.get(index), "Null value"); diff --git a/infer/src/nullsafe/modelTables.ml b/infer/src/nullsafe/modelTables.ml index 44b916b0f..e0620eff7 100644 --- a/infer/src/nullsafe/modelTables.ml +++ b/infer/src/nullsafe/modelTables.ml @@ -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" )