@@ -13,12 +13,10 @@ let try_custom = SpeculationKit.try_custom
1313let flow_t_unsafe cx (l , u ) =
1414 SpeculationKit. try_singleton_throw_on_failure cx DepthTrace. dummy_trace l (UseT (unknown_use, u))
1515
16- let speculation_error_opt cx t u =
16+ let is_flow_successful cx t u =
1717 match SpeculationKit. try_singleton_throw_on_failure cx DepthTrace. dummy_trace t u with
18- | exception Flow_js_utils. SpeculationSingletonError e -> Some e
19- | () -> None
20-
21- let is_flow_successful cx t u = Base.Option. is_none (speculation_error_opt cx t u)
18+ | exception Flow_js_utils. SpeculationSingletonError -> false
19+ | () -> true
2220
2321let is_subtyping_successful cx l u = is_flow_successful cx l (UseT (unknown_use, u))
2422
@@ -27,18 +25,13 @@ let resolved_lower_flow_unsafe cx r (l, u) =
2725 | [] -> ()
2826 | [l] -> Flow_js. flow cx (l, u)
2927 | l0 :: ls ->
30- let error_opt =
31- Base.List. fold ls ~init: (speculation_error_opt cx l0 u) ~f: (fun acc l ->
32- let r = speculation_error_opt cx l u in
33- match (acc, r) with
34- | (None, _ ) -> None
35- | (_ , None) -> None
36- | (Some e , Some _ ) -> Some e
28+ let successful =
29+ Base.List. fold ls ~init: (is_flow_successful cx l0 u) ~f: (fun acc l ->
30+ let r = is_flow_successful cx l u in
31+ acc || r
3732 )
3833 in
39- (match error_opt with
40- | None -> ()
41- | Some e -> raise (Flow_js_utils. SpeculationSingletonError e))
34+ if not successful then raise Flow_js_utils. SpeculationSingletonError
4235
4336let resolved_lower_flow_t_unsafe cx r (l , u ) =
4437 resolved_lower_flow_unsafe cx r (l, UseT (unknown_use, u))
@@ -48,20 +41,15 @@ let resolved_upper_flow_t_unsafe cx r (l, u) =
4841 | [] -> ()
4942 | [u] -> Flow_js. flow_t cx (l, u)
5043 | u0 :: us ->
51- let error_opt =
44+ let successful =
5245 Base.List. fold
5346 us
54- ~init: (speculation_error_opt cx l (UseT (unknown_use, u0)))
47+ ~init: (is_flow_successful cx l (UseT (unknown_use, u0)))
5548 ~f: (fun acc u ->
56- let r = speculation_error_opt cx l (UseT (unknown_use, u)) in
57- match (acc, r) with
58- | (None, _ ) -> None
59- | (_ , None) -> None
60- | (Some e , Some _ ) -> Some e)
49+ let r = is_flow_successful cx l (UseT (unknown_use, u)) in
50+ acc || r)
6151 in
62- (match error_opt with
63- | None -> ()
64- | Some e -> raise (Flow_js_utils. SpeculationSingletonError e))
52+ if not successful then raise Flow_js_utils. SpeculationSingletonError
6553
6654let get_method_type_unsafe cx t reason propref =
6755 Tvar. mk_where cx reason (fun prop_t ->
@@ -76,5 +64,5 @@ let get_method_type_opt cx t reason propref =
7664 resolved_lower_flow_unsafe cx reason (t, use_t)
7765 )
7866 with
79- | exception Flow_js_utils. SpeculationSingletonError _ -> None
67+ | exception Flow_js_utils. SpeculationSingletonError -> None
8068 | t -> Some t
0 commit comments