From 8450ac36d803d9ec105a3a4a6932d14d08ac5c07 Mon Sep 17 00:00:00 2001 From: Nikos Gorogiannis Date: Fri, 26 Apr 2019 06:00:14 -0700 Subject: [PATCH] [trivial] procname should implement Hashable Summary: No reason to use custom function name and not implement `Hashable`. Reviewed By: mbouaziz Differential Revision: D15097603 fbshipit-source-id: 7303fc15e --- infer/src/IR/Typ.ml | 6 ++---- infer/src/IR/Typ.mli | 2 +- infer/src/nullsafe/typeErr.ml | 12 ++++++------ 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/infer/src/IR/Typ.ml b/infer/src/IR/Typ.ml index fda61124c..808d5831a 100644 --- a/infer/src/IR/Typ.ml +++ b/infer/src/IR/Typ.ml @@ -986,6 +986,7 @@ module Procname = struct let equal = [%compare.equal: t] + (** hash function for procname *) let hash = Hashtbl.hash let with_block_parameters base blocks = WithBlockParameters (base, blocks) @@ -1278,15 +1279,12 @@ module Procname = struct let describe f pn = F.pp_print_string f (hashable_name pn) - (** hash function for procname *) - let hash_pname = Hashtbl.hash - module Hashable = struct type nonrec t = t let equal = equal - let hash = hash_pname + let hash = hash end module Hash = Hashtbl.Make (Hashable) diff --git a/infer/src/IR/Typ.mli b/infer/src/IR/Typ.mli index f0b084604..4ad3e947b 100644 --- a/infer/src/IR/Typ.mli +++ b/infer/src/IR/Typ.mli @@ -552,7 +552,7 @@ being the name of the struct, [None] means the parameter is of some other type. val is_objc_block : t -> bool (** Return whether the procname is a block procname. *) - val hash_pname : t -> int + val hash : t -> int (** Hash function for procname. *) val is_c_method : t -> bool diff --git a/infer/src/nullsafe/typeErr.ml b/infer/src/nullsafe/typeErr.ml index d964830ce..cec4d1604 100644 --- a/infer/src/nullsafe/typeErr.ml +++ b/infer/src/nullsafe/typeErr.ml @@ -113,18 +113,18 @@ module H = Hashtbl.Make (struct | Null_field_access (so, fn, _, _) -> Hashtbl.hash (6, string_opt_hash so, string_hash (Typ.Fieldname.to_string fn)) | Call_receiver_annotation_inconsistent (ann, so, pn, _) -> - Hashtbl.hash (7, ann, string_opt_hash so, Typ.Procname.hash_pname pn) + Hashtbl.hash (7, ann, string_opt_hash so, Typ.Procname.hash pn) | Parameter_annotation_inconsistent (ann, s, n, pn, _, _) -> - Hashtbl.hash (8, ann, string_hash s, n, Typ.Procname.hash_pname pn) + Hashtbl.hash (8, ann, string_hash s, n, Typ.Procname.hash pn) | Return_annotation_inconsistent (ann, pn, _) -> - Hashtbl.hash (9, ann, Typ.Procname.hash_pname pn) + Hashtbl.hash (9, ann, Typ.Procname.hash pn) | Return_over_annotated pn -> - Hashtbl.hash (10, Typ.Procname.hash_pname pn) + Hashtbl.hash (10, Typ.Procname.hash pn) | Inconsistent_subclass_return_annotation (pn, opn) -> - Hashtbl.hash (11, Typ.Procname.hash_pname pn, Typ.Procname.hash_pname opn) + Hashtbl.hash (11, Typ.Procname.hash pn, Typ.Procname.hash opn) | Inconsistent_subclass_parameter_annotation (param_name, pos, pn, opn) -> let pn_hash = string_hash param_name in - Hashtbl.hash (12, pn_hash, pos, Typ.Procname.hash_pname pn, Typ.Procname.hash_pname opn) + Hashtbl.hash (12, pn_hash, pos, Typ.Procname.hash pn, Typ.Procname.hash opn) let hash (err_inst, instr_ref_opt) =