@ -16,10 +16,7 @@ module L = Logging
* )
* )
type t =
type t =
{ nullsafe_mode : NullsafeMode . t
{ nullsafe_mode : NullsafeMode . t ; kind : kind ; ret : ret_signature ; params : param_signature list }
; model_source : model_source option
; ret : ret_signature
; params : param_signature list }
[ @@ deriving compare ]
[ @@ deriving compare ]
and ret_signature = { ret_annotation_deprecated : Annot . Item . t ; ret_annotated_type : AnnotatedType . t }
and ret_signature = { ret_annotation_deprecated : Annot . Item . t ; ret_annotated_type : AnnotatedType . t }
@ -31,7 +28,12 @@ and param_signature =
; param_annotated_type : AnnotatedType . t }
; param_annotated_type : AnnotatedType . t }
[ @@ deriving compare ]
[ @@ deriving compare ]
and model_source = InternalModel | ThirdPartyRepo of { filename : string ; line_number : int }
and kind = FirstParty | ThirdParty of third_party_model_source [ @ deriving compare ]
and third_party_model_source =
| Unregistered
| ModelledInternally
| InThirdPartyRepo of { filename : string ; line_number : int }
[ @@ deriving compare ]
[ @@ deriving compare ]
(* get nullability of method's return type given its annotations and information about its params *)
(* get nullability of method's return type given its annotations and information about its params *)
@ -102,7 +104,8 @@ let get ~is_callee_in_trust_list ~nullsafe_mode
; mangled
; mangled
; param_annotated_type = AnnotatedType . { nullability ; typ } } )
; param_annotated_type = AnnotatedType . { nullability ; typ } } )
in
in
{ nullsafe_mode ; model_source = None ; ret ; params }
let kind = if is_third_party then ThirdParty Unregistered else FirstParty in
{ nullsafe_mode ; kind ; ret ; params }
let get_for_class_under_analysis tenv proc_attributes =
let get_for_class_under_analysis tenv proc_attributes =
@ -191,7 +194,11 @@ let set_modelled_nullability proc_name asig model_source (nullability_for_ret, p
in
in
model_param_nullability asig . params params_nullability
model_param_nullability asig . params params_nullability
in
in
{ asig with
match model_source with
ret = set_modelled_nullability_for_ret asig . ret nullability_for_ret
| Unregistered ->
; model_source = Some model_source
Logging . die InternalError " the method should be either internally or externally modelled "
; params = final_params }
| ModelledInternally | InThirdPartyRepo _ ->
{ asig with
ret = set_modelled_nullability_for_ret asig . ret nullability_for_ret
; kind = ThirdParty model_source
; params = final_params }