From d4bea60440281a30c1efe7981a4e9de8951b4b41 Mon Sep 17 00:00:00 2001 From: Mitya Lyubarskiy Date: Tue, 11 Aug 2020 06:24:37 -0700 Subject: [PATCH] [nullsafe][refactor] Migrate DereferenceRule to Procname.Java.t Summary: This is part of work aimed to reduce number of language-agnostic methods used in Nullsafe codebase. Reviewed By: artempyanykh Differential Revision: D23052328 fbshipit-source-id: 2b69f5f7a --- infer/src/IR/Procname.ml | 2 ++ infer/src/IR/Procname.mli | 2 ++ infer/src/nullsafe/DereferenceRule.ml | 4 ++-- infer/src/nullsafe/DereferenceRule.mli | 2 +- infer/src/nullsafe/typeCheck.ml | 2 +- 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/infer/src/IR/Procname.ml b/infer/src/IR/Procname.ml index 750e44c8d..b6a073e9e 100644 --- a/infer/src/IR/Procname.ml +++ b/infer/src/IR/Procname.ml @@ -108,6 +108,8 @@ module Java = struct F.fprintf fmt "%a(%s)" pp_method_name j params + let to_simplified_string ?(withclass = false) = Pp.string_of_pp (pp ~withclass Simple) + let get_return_typ pname_java = Option.value ~default:Typ.void pname_java.return_type let is_close {method_name} = String.equal method_name "close" diff --git a/infer/src/IR/Procname.mli b/infer/src/IR/Procname.mli index c1efa816e..ae0432202 100644 --- a/infer/src/IR/Procname.mli +++ b/infer/src/IR/Procname.mli @@ -19,6 +19,8 @@ module Java : sig type t [@@deriving compare] + val to_simplified_string : ?withclass:bool -> t -> string + val constructor_method_name : string val class_initializer_method_name : string diff --git a/infer/src/nullsafe/DereferenceRule.ml b/infer/src/nullsafe/DereferenceRule.ml index f3b53803a..647a57d5f 100644 --- a/infer/src/nullsafe/DereferenceRule.ml +++ b/infer/src/nullsafe/DereferenceRule.ml @@ -12,7 +12,7 @@ module ReportableViolation = struct type t = {nullsafe_mode: NullsafeMode.t; violation: violation} type dereference_type = - | MethodCall of Procname.t + | MethodCall of Procname.Java.t | AccessToField of Fieldname.t | AccessByIndex of {index_desc: string} | ArrayLengthAccess @@ -61,7 +61,7 @@ module ReportableViolation = struct match dereference_type with | MethodCall method_name -> Format.sprintf "calling %s" - (MF.monospaced_to_string (Procname.to_simplified_string method_name)) + (MF.monospaced_to_string (Procname.Java.to_simplified_string method_name)) | AccessToField field_name -> Format.sprintf "accessing field %s" (MF.monospaced_to_string (Fieldname.to_simplified_string field_name)) diff --git a/infer/src/nullsafe/DereferenceRule.mli b/infer/src/nullsafe/DereferenceRule.mli index 7bf4b5bde..732ae357d 100644 --- a/infer/src/nullsafe/DereferenceRule.mli +++ b/infer/src/nullsafe/DereferenceRule.mli @@ -21,7 +21,7 @@ module ReportableViolation : sig type t type dereference_type = - | MethodCall of Procname.t + | MethodCall of Procname.Java.t | AccessToField of Fieldname.t | AccessByIndex of {index_desc: string} | ArrayLengthAccess diff --git a/infer/src/nullsafe/typeCheck.ml b/infer/src/nullsafe/typeCheck.ml index 5d9d4c61a..7521d4140 100644 --- a/infer/src/nullsafe/typeCheck.ml +++ b/infer/src/nullsafe/typeCheck.ml @@ -1058,7 +1058,7 @@ let calc_typestate_after_call if not is_anonymous_inner_class_constructor then ( if cflags.CallFlags.cf_virtual && checks.eradicate then EradicateChecks.check_call_receiver analysis_data ~nullsafe_mode find_canonical_duplicate - node typestate1 call_params callee_pname instr_ref loc + node typestate1 call_params callee_pname_java instr_ref loc (typecheck_expr analysis_data ~nullsafe_mode find_canonical_duplicate calls_this checks) ; if checks.eradicate then EradicateChecks.check_call_parameters analysis_data ~nullsafe_mode