Skip to content

Commit

Permalink
[flow] Kill ConditionalTypeEval use_op
Browse files Browse the repository at this point in the history
Summary:
I re-discovered this while looking through the error printing code, and found the message for that use_op not that meaningful.

This use_op should never appear to the end user, since the evaluation of conditional type should never fail (especially after the previous diff to ensure that we no longer error on underconstrained infer).

Changelog: [internal]

Reviewed By: panagosg7

Differential Revision: D56041988

fbshipit-source-id: 08aa0b80abf94bdb1ca1df66b29883b02d05908c
  • Loading branch information
SamChou19815 authored and facebook-github-bot committed Apr 13, 2024
1 parent 18a142c commit a8d7b05
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 38 deletions.
6 changes: 0 additions & 6 deletions src/typing/errors/flow_error.ml
Original file line number Diff line number Diff line change
Expand Up @@ -617,12 +617,6 @@ let rec make_error_printable :
frames
bound
[text "Cannot use "; desc bound; text " as the bound of infer type "; desc infer]
| Op (ConditionalTypeEval { check_type_reason; extends_type_reason }) ->
root
loc
frames
check_type_reason
[text "Cannot check "; desc check_type_reason; text " against "; desc extends_type_reason]
| Frame (FunParam _, Op (JSXCreateElement { op; component; _ }))
| Op (JSXCreateElement { op; component; _ }) ->
root_with_specific_reason
Expand Down
1 change: 0 additions & 1 deletion src/typing/flow_js.ml
Original file line number Diff line number Diff line change
Expand Up @@ -8919,7 +8919,6 @@ struct
| GetProperty _
| IndexedTypeAccess _
| InferBoundCompatibilityCheck _
| ConditionalTypeEval _
| EvalMappedType _
| SetProperty _
| UpdateProperty _
Expand Down
5 changes: 0 additions & 5 deletions src/typing/type.ml
Original file line number Diff line number Diff line change
Expand Up @@ -399,10 +399,6 @@ module rec TypeTerm : sig
_object: 'loc virtual_reason;
index: 'loc virtual_reason;
}
| ConditionalTypeEval of {
check_type_reason: 'loc virtual_reason;
extends_type_reason: 'loc virtual_reason;
}
| InitField of {
op: 'loc virtual_reason;
body: 'loc virtual_reason;
Expand Down Expand Up @@ -4135,7 +4131,6 @@ let string_of_root_use_op (type a) : a virtual_root_use_op -> string = function
| GetProperty _ -> "GetProperty"
| IndexedTypeAccess _ -> "IndexedTypeAccess"
| InferBoundCompatibilityCheck _ -> "InferBoundCompatibilityCheck"
| ConditionalTypeEval _ -> "ConditionalTypeEval"
| JSXCreateElement _ -> "JSXCreateElement"
| ReactCreateElementCall _ -> "ReactCreateElementCall"
| ReactGetIntrinsic _ -> "ReactGetIntrinsic"
Expand Down
6 changes: 0 additions & 6 deletions src/typing/typeUtil.ml
Original file line number Diff line number Diff line change
Expand Up @@ -652,12 +652,6 @@ let rec mod_loc_of_virtual_use_op f =
IndexedTypeAccess { _object = mod_reason _object; index = mod_reason index }
| InferBoundCompatibilityCheck { bound; infer } ->
InferBoundCompatibilityCheck { bound = mod_reason bound; infer = mod_reason infer }
| ConditionalTypeEval { check_type_reason; extends_type_reason } ->
ConditionalTypeEval
{
check_type_reason = mod_reason check_type_reason;
extends_type_reason = mod_reason extends_type_reason;
}
| JSXCreateElement { op; component } ->
JSXCreateElement { op = mod_reason op; component = mod_reason component }
| ReactCreateElementCall { op; component; children } ->
Expand Down
11 changes: 1 addition & 10 deletions src/typing/type_annotation.ml
Original file line number Diff line number Diff line change
Expand Up @@ -562,20 +562,11 @@ module Make (ConsGen : Type_annotation_sig.ConsGen) (Statement : Statement_sig.S
let (((_, false_t), _) as false_type) = convert env false_type in
let t =
let reason = mk_reason RConditionalType loc in
let use_op =
Op
(ConditionalTypeEval
{
check_type_reason = reason_of_t check_t;
extends_type_reason = reason_of_t extends_t;
}
)
in
let destructor =
ConditionalType { distributive_tparam_name; infer_tparams; extends_t; true_t; false_t }
in
let cx = env.cx in
mk_type_destructor cx use_op reason check_t destructor (mk_eval_id cx loc)
mk_type_destructor cx unknown_use reason check_t destructor (mk_eval_id cx loc)
in
( (loc, t),
Conditional { Conditional.check_type; extends_type; true_type; false_type; comments }
Expand Down
11 changes: 1 addition & 10 deletions src/typing/type_sig_merge.ml
Original file line number Diff line number Diff line change
Expand Up @@ -807,20 +807,11 @@ and merge_annot env file = function
in
let true_t = merge { env with tps = tps_for_true_type } file true_type in
let false_t = merge env file false_type in
let use_op =
Type.Op
(Type.ConditionalTypeEval
{
check_type_reason = TypeUtil.reason_of_t check_t;
extends_type_reason = TypeUtil.reason_of_t extends_t;
}
)
in
Type.(
EvalT
( check_t,
TypeDestructorT
( use_op,
( unknown_use,
reason,
ConditionalType
{ distributive_tparam_name; infer_tparams; extends_t; true_t; false_t }
Expand Down

0 comments on commit a8d7b05

Please sign in to comment.