[nullsafe][refactor] Migrate Overannotated rule to Procname.Java.t

Summary:
This is part of work aimed to reduce usage of language-agnostics modules
in Java-specific parts of nullsafe.

Reviewed By: ngorogiannis

Differential Revision: D23075333

fbshipit-source-id: 4029732b4
master
Mitya Lyubarskiy 4 years ago committed by Facebook GitHub Bot
parent 7d0671910a
commit 937d5386d1

@ -27,7 +27,7 @@ let check ~what ~by_rhs_upper_bound =
type violation_type =
| FieldOverAnnoted of Fieldname.t
| ReturnOverAnnotated of Procname.t (** Return value of a method can be made non-nullable *)
| ReturnOverAnnotated of Procname.Java.t (** Return value of a method can be made non-nullable *)
[@@deriving compare]
let violation_description _ violation_type =
@ -41,5 +41,5 @@ let violation_description _ violation_type =
MF.pp_monospaced nullable_annotation
| ReturnOverAnnotated proc_name ->
Format.asprintf "Method %a is annotated with %a but never returns null." MF.pp_monospaced
(Procname.to_simplified_string proc_name)
(Procname.Java.to_simplified_string proc_name)
MF.pp_monospaced nullable_annotation

@ -26,7 +26,7 @@ val check : what:Nullability.t -> by_rhs_upper_bound:Nullability.t -> (unit, vio
type violation_type =
| FieldOverAnnoted of Fieldname.t
| ReturnOverAnnotated of Procname.t (** Return value of a method can be made non-nullable *)
| ReturnOverAnnotated of Procname.Java.t (** Return value of a method can be made non-nullable *)
[@@deriving compare]
val violation_description : violation -> violation_type -> string

@ -339,9 +339,8 @@ let check_return_not_nullable analysis_data ~nullsafe_mode ~java_pname find_cano
None ~nullsafe_mode loc )
let check_return_overrannotated
({IntraproceduralAnalysis.proc_desc= curr_pdesc; _} as analysis_data) find_canonical_duplicate
loc ~nullsafe_mode (ret_signature : AnnotatedSignature.ret_signature) ret_inferred_nullability =
let check_return_overrannotated ~java_pname analysis_data find_canonical_duplicate loc
~nullsafe_mode (ret_signature : AnnotatedSignature.ret_signature) ret_inferred_nullability =
(* Returning from a function is essentially an assignment the actual return value to the formal `return` *)
let what = AnnotatedNullability.get_nullability ret_signature.ret_annotated_type.nullability in
(* In our CFG implementation, there is only one place where we return from a function
@ -351,9 +350,8 @@ let check_return_overrannotated
let by_rhs_upper_bound = InferredNullability.get_nullability ret_inferred_nullability in
Result.iter_error (OverAnnotatedRule.check ~what ~by_rhs_upper_bound)
~f:(fun over_annotated_violation ->
let curr_pname = Procdesc.get_proc_name curr_pdesc in
TypeErr.register_error analysis_data find_canonical_duplicate
(Over_annotation {over_annotated_violation; violation_type= ReturnOverAnnotated curr_pname})
(Over_annotation {over_annotated_violation; violation_type= ReturnOverAnnotated java_pname})
None ~nullsafe_mode loc )
@ -371,7 +369,7 @@ let check_return_annotation analysis_data ~java_pname find_canonical_duplicate r
~nullsafe_mode:annotated_signature.nullsafe_mode find_canonical_duplicate loc
annotated_signature.ret ret_inferred_nullability ;
if Config.eradicate_return_over_annotated then
check_return_overrannotated analysis_data find_canonical_duplicate loc
check_return_overrannotated ~java_pname analysis_data find_canonical_duplicate loc
annotated_signature.ret ~nullsafe_mode:annotated_signature.nullsafe_mode
ret_inferred_nullability
| None ->

Loading…
Cancel
Save