[nullsafe][annotation graph] Issue a provisional violation in assignments between two provisionally nullables

Summary:
This change is what makes the annotation graph a _graph_.
Now we can detect places when adding one annotation causes an issue that can be
fixed by adding another annotation.

Reviewed By: artempyanykh

Differential Revision: D24650979

fbshipit-source-id: b8452b822
master
Mitya Lyubarskiy 4 years ago committed by Facebook GitHub Bot
parent 18ccc321c8
commit c07223293d

@ -266,9 +266,19 @@ module ReportableViolation = struct
end end
let check ~lhs ~rhs = let check ~lhs ~rhs =
let is_subtype = match (lhs, InferredNullability.get_nullability rhs) with
Nullability.is_subtype | AnnotatedNullability.ProvisionallyNullable _, Nullability.ProvisionallyNullable ->
~supertype:(AnnotatedNullability.get_nullability lhs) (* This is a special case. Assignment of something that comes from provisionally nullable annotation to something that
~subtype:(InferredNullability.get_nullability rhs) is annotated as provisionally nullable is a (provisional) violation.
in (With an exception when it is an assignment to the same annotation e.g. in recursion calls;
Result.ok_if_true is_subtype ~error:{lhs; rhs} but such exceptions are non-essential for the purposes of calculation of the annotation graph.
)
*)
Error {lhs; rhs}
| _ ->
let is_subtype =
Nullability.is_subtype
~supertype:(AnnotatedNullability.get_nullability lhs)
~subtype:(InferredNullability.get_nullability rhs)
in
Result.ok_if_true is_subtype ~error:{lhs; rhs}

Loading…
Cancel
Save