[nullsafe][refactor] TypeState.ml cleanup: Remove uneccessary calls

Summary:
These two methods are called in processing prune instructions, when
instruction is Prune(expr == null) and Prune(expr != null), to correctly
infer nullability in corresponding branches.

Typechecking underlying expr makes little sense for two reasons:
1. In practice, expr it is as simple as a temporary SIL variable
2. If the idea is defensively typecheck everything for case when SIL
produces crazy expressions, well, that is not going to work: the code
around ignores many other forms of expressions, e.g. everything where
expr = <something not equal to null literal>. So this is inconsistent.

This will simplify further cleanup, see follow up diffs

Reviewed By: ngorogiannis

Differential Revision: D19743826

fbshipit-source-id: 319a80ee7
master
Mitya Lyubarskiy 5 years ago committed by Facebook Github Bot
parent eded9141d9
commit a4a4b92690

@ -738,8 +738,6 @@ let rec check_condition_for_sil_prune tenv idenv calls_this find_canonical_dupli
| Exp.BinOp (Binop.Eq, Exp.Const (Const.Cint i), e) | Exp.BinOp (Binop.Eq, Exp.Const (Const.Cint i), e)
| Exp.BinOp (Binop.Eq, e, Exp.Const (Const.Cint i)) | Exp.BinOp (Binop.Eq, e, Exp.Const (Const.Cint i))
when IntLit.iszero i -> ( when IntLit.iszero i -> (
typecheck_expr_for_errors ~nullsafe_mode find_canonical_duplicate curr_pdesc calls_this checks
tenv original_node instr_ref typestate e loc ;
let typestate1, e1, from_call = let typestate1, e1, from_call =
match from_is_true_on_null e with match from_is_true_on_null e with
| Some e1 -> | Some e1 ->
@ -768,8 +766,6 @@ let rec check_condition_for_sil_prune tenv idenv calls_this find_canonical_dupli
| Exp.BinOp (Binop.Ne, Exp.Const (Const.Cint i), e) | Exp.BinOp (Binop.Ne, Exp.Const (Const.Cint i), e)
| Exp.BinOp (Binop.Ne, e, Exp.Const (Const.Cint i)) | Exp.BinOp (Binop.Ne, e, Exp.Const (Const.Cint i))
when IntLit.iszero i -> ( when IntLit.iszero i -> (
typecheck_expr_for_errors ~nullsafe_mode find_canonical_duplicate curr_pdesc calls_this checks
tenv original_node instr_ref typestate e loc ;
let typestate1, e1, from_call = let typestate1, e1, from_call =
match from_instanceof e with match from_instanceof e with
| Some e1 -> | Some e1 ->

Loading…
Cancel
Save