diff --git a/infer/src/concurrency/RacerD.ml b/infer/src/concurrency/RacerD.ml index 4cda31dc7..0383c9213 100644 --- a/infer/src/concurrency/RacerD.ml +++ b/infer/src/concurrency/RacerD.ml @@ -1005,17 +1005,22 @@ let get_reporting_explanation_java report_kind tenv pname thread = "@\n Reporting because current method is annotated %a or overrides an annotated method." MF.pp_monospaced "@ThreadSafe") else - match get_current_class_and_threadsafe_superclasses tenv pname with - | Some (current_class, (thread_safe_class :: _ as thread_safe_annotated_classes)) -> - Some - ( if List.mem ~equal:Typ.Name.equal thread_safe_annotated_classes current_class then - F.asprintf "@\n Reporting because the current class is annotated %a" - MF.pp_monospaced "@ThreadSafe" - else - F.asprintf "@\n Reporting because a superclass %a is annotated %a" - (MF.wrap_monospaced Typ.Name.pp) thread_safe_class MF.pp_monospaced "@ThreadSafe" ) - | _ -> - None + match FbThreadSafety.get_fbthreadsafe_class_annot pname tenv with + | Some (qual, annot) -> + Some (FbThreadSafety.message_fbthreadsafe_class qual annot) + | None -> + match get_current_class_and_threadsafe_superclasses tenv pname with + | Some (current_class, (thread_safe_class :: _ as thread_safe_annotated_classes)) -> + Some + ( if List.mem ~equal:Typ.Name.equal thread_safe_annotated_classes current_class then + F.asprintf "@\n Reporting because the current class is annotated %a" + MF.pp_monospaced "@ThreadSafe" + else + F.asprintf "@\n Reporting because a superclass %a is annotated %a" + (MF.wrap_monospaced Typ.Name.pp) thread_safe_class MF.pp_monospaced "@ThreadSafe" + ) + | _ -> + None in match (report_kind, annotation_explanation_opt) with | UnannotatedInterface, Some threadsafe_explanation -> @@ -1714,4 +1719,3 @@ let file_analysis {Callbacks.procedures} = else (module MayAliasQuotientedAccessListMap) ) class_env)) (aggregate_by_class procedures) - diff --git a/infer/src/opensource/FbThreadSafety.ml b/infer/src/opensource/FbThreadSafety.ml index e275e4796..7bd67df14 100644 --- a/infer/src/opensource/FbThreadSafety.ml +++ b/infer/src/opensource/FbThreadSafety.ml @@ -12,3 +12,7 @@ open! IStd let is_custom_init _ _ = false let is_logging_method _ = false + +let get_fbthreadsafe_class_annot _ _ = None + +let message_fbthreadsafe_class _ _ = "" diff --git a/infer/src/opensource/FbThreadSafety.mli b/infer/src/opensource/FbThreadSafety.mli index db65547ea..47be0de24 100644 --- a/infer/src/opensource/FbThreadSafety.mli +++ b/infer/src/opensource/FbThreadSafety.mli @@ -12,3 +12,7 @@ open! IStd val is_custom_init : Tenv.t -> Typ.Procname.t -> bool val is_logging_method : Typ.Procname.t -> bool + +val get_fbthreadsafe_class_annot : Typ.Procname.t -> Tenv.t -> (string * string) option + +val message_fbthreadsafe_class : string -> string -> string