From ffe1b55f42e7c64a9cce3350d18df0ff3deaf2b0 Mon Sep 17 00:00:00 2001 From: Mitya Lyubarskiy Date: Fri, 30 Oct 2020 05:13:00 -0700 Subject: [PATCH] [nullsafe] Remove uneccessary logic in chosing join priority Summary: This was perhaps needed at some point, but now there is no need in this. See the next diff that refactors InferredNullability so we store all joinee results there. Reviewed By: artempyanykh Differential Revision: D24621413 fbshipit-source-id: d6f406b87 --- infer/src/nullsafe/InferredNullability.ml | 4 ++-- infer/src/nullsafe/typeOrigin.ml | 10 ---------- infer/src/nullsafe/typeOrigin.mli | 3 --- 3 files changed, 2 insertions(+), 15 deletions(-) diff --git a/infer/src/nullsafe/InferredNullability.ml b/infer/src/nullsafe/InferredNullability.ml index e8f017efa..55a98fbb0 100644 --- a/infer/src/nullsafe/InferredNullability.ml +++ b/infer/src/nullsafe/InferredNullability.ml @@ -39,9 +39,9 @@ let join t1 t2 = t2.origin | false, false | true, true -> (* Nullability is not fully determined by neither t1 nor t2 - Let TypeOrigin logic to decide what to prefer in this case. + Picking the left one for stability *) - TypeOrigin.join t1.origin t2.origin + t1.origin in {nullability= joined_nullability; origin= joined_origin} diff --git a/infer/src/nullsafe/typeOrigin.ml b/infer/src/nullsafe/typeOrigin.ml index c99c2b57d..01416d1ca 100644 --- a/infer/src/nullsafe/typeOrigin.ml +++ b/infer/src/nullsafe/typeOrigin.ml @@ -194,13 +194,3 @@ let get_description origin = (* A technical origin *) | OptimisticFallback -> None - - -let join o1 o2 = - match (o1, o2) with - | Field _, (NullConst _ | NonnullConst _ | CurrMethodParameter _ | This | MethodCall _ | New) -> - (* low priority to Field, to support field initialization patterns *) - o2 - | _ -> - (* left priority *) - o1 diff --git a/infer/src/nullsafe/typeOrigin.mli b/infer/src/nullsafe/typeOrigin.mli index 44d29a89a..1bf7ba8a4 100644 --- a/infer/src/nullsafe/typeOrigin.mli +++ b/infer/src/nullsafe/typeOrigin.mli @@ -52,8 +52,5 @@ val get_nullability : t -> Nullability.t val get_description : t -> string option (** Get a description to be used for error messages. *) -val join : t -> t -> t -(** Join with left priority *) - val to_string : t -> string (** Raw string representation. *)