diff --git a/infer/src/concurrency/RacerD.ml b/infer/src/concurrency/RacerD.ml index 3cc99677e..4ab5b3476 100644 --- a/infer/src/concurrency/RacerD.ml +++ b/infer/src/concurrency/RacerD.ml @@ -186,17 +186,6 @@ module TransferFunctions (CFG : ProcCfg.S) = struct let should_assume_returns_ownership (call_flags : CallFlags.t) actuals = (not call_flags.cf_interface) && List.is_empty actuals in - let is_abstract_getthis_like callee = - Ondemand.get_proc_desc callee - |> Option.exists ~f:(fun callee_pdesc -> - (Procdesc.get_attributes callee_pdesc).ProcAttributes.is_abstract - && - match Procdesc.get_formals callee_pdesc with - | [(_, typ)] when Typ.equal typ (snd ret_base) -> - true - | _ -> - false ) - in if is_box callee_pname then match actuals with | HilExp.AccessExpression actual_access_expr :: _ -> diff --git a/infer/src/concurrency/RacerDModels.ml b/infer/src/concurrency/RacerDModels.ml index f1669aee7..9925e0ad3 100644 --- a/infer/src/concurrency/RacerDModels.ml +++ b/infer/src/concurrency/RacerDModels.ml @@ -462,3 +462,17 @@ let is_synchronized_container callee_pname (access_exp : HilExp.AccessExpression false ) | _ -> false + + +(** check that callee is abstract and accepts one argument. In addition, its argument type must be + equal to its return type. *) +let is_abstract_getthis_like callee = + attrs_of_pname callee + |> Option.exists ~f:(fun (attrs : ProcAttributes.t) -> + attrs.is_abstract + && + match attrs.formals with + | [(_, typ)] when Typ.equal typ attrs.ret_type -> + true + | _ -> + false ) diff --git a/infer/src/concurrency/RacerDModels.mli b/infer/src/concurrency/RacerDModels.mli index 678657dfb..fd8583fb9 100644 --- a/infer/src/concurrency/RacerDModels.mli +++ b/infer/src/concurrency/RacerDModels.mli @@ -52,3 +52,6 @@ val should_flag_interface_call : Tenv.t -> HilExp.t list -> CallFlags.t -> Typ.P val is_synchronized_container : Typ.Procname.t -> HilExp.AccessExpression.t -> Tenv.t -> bool (** is a call on an access expression to a method of a synchronized container? *) + +val is_abstract_getthis_like : Typ.Procname.t -> bool +(** is the callee an abstract method with one argument where argument type is equal to return type *)