diff --git a/infer/src/backend/symExec.ml b/infer/src/backend/symExec.ml index f266e085d..0af319e92 100644 --- a/infer/src/backend/symExec.ml +++ b/infer/src/backend/symExec.ml @@ -1135,6 +1135,7 @@ and add_constraints_on_retval pdesc prop exp typ callee_pname callee_loc = IList.fold_left bind_exp prop (Prop.get_sigma prop) in (* bind return id to the abducted value pointed to by the pvar we introduced *) bind_exp_to_abducted_val exp abducted_ret_pv prop + |> add_ret_non_null exp typ else add_ret_non_null exp typ prop and add_constraints_on_actuals_by_ref prop actuals_by_ref callee_pname callee_loc = diff --git a/infer/tests/codetoanalyze/java/infer/NullPointerExceptions.java b/infer/tests/codetoanalyze/java/infer/NullPointerExceptions.java index 764fad52a..3a5743125 100644 --- a/infer/tests/codetoanalyze/java/infer/NullPointerExceptions.java +++ b/infer/tests/codetoanalyze/java/infer/NullPointerExceptions.java @@ -435,5 +435,21 @@ public class NullPointerExceptions { File[] files = dir.listFiles(); return files.length; // expect possible NullPointerException as files == null is possible } + + native Object unknownFunc(); + + Object callUnknownFunc() { + return unknownFunc(); + } + + void dontReportOnNullableDirectReassignmentToUnknown(@Nullable Object o) { + o = unknownFunc(); + o.toString(); + } + + void dontReportOnNullableIndirectReassignmentToUnknown(@Nullable Object o) { + o = callUnknownFunc(); + o.toString(); + } }