[nullsafe] --no-nullsafe-optimistic-third-party-in-default-mode is optimistic about Inheritance check

Summary: This is needed for migration purposes.

Reviewed By: artempyanykh

Differential Revision: D26543726

fbshipit-source-id: 2dd8928bb
master
Mitya Lyubarskiy 4 years ago committed by Facebook GitHub Bot
parent 1e36735f14
commit 481068d3da

@ -95,13 +95,20 @@ module ReportableViolation = struct
end end
let check type_role ~base ~overridden = let check type_role ~base ~overridden =
let subtype, supertype = if Nullability.equal Nullability.ThirdPartyNonnull base then
match type_role with (* In context of inheritance check, third party declarations in base are treated optimistically.
| Ret -> Meaning return values are assumed [@Nullable] and params are assumed [@NonNull].
(* covariance for ret *) This is done for compatibility reasons so existing [@Nullsafe] classes are preserved Nullsafe.
(overridden, base) *)
| Param -> Ok ()
(* contravariance for param *) else
(base, overridden) let subtype, supertype =
in match type_role with
Result.ok_if_true (Nullability.is_subtype ~subtype ~supertype) ~error:{base; overridden} | Ret ->
(* covariance for ret *)
(overridden, base)
| Param ->
(* contravariance for param *)
(base, overridden)
in
Result.ok_if_true (Nullability.is_subtype ~subtype ~supertype) ~error:{base; overridden}

Loading…
Cancel
Save