Skip to content

Commit 9d283ba

Browse files
committed
remove duplicated is_async function
1 parent 4d1e792 commit 9d283ba

File tree

5 files changed

+9
-13
lines changed

5 files changed

+9
-13
lines changed

jscomp/frontend/ast_attributes.ml

+2-8
Original file line numberDiff line numberDiff line change
@@ -166,14 +166,8 @@ let is_inline : attr -> bool =
166166

167167
let has_inline_payload (attrs : t) = Ext_list.find_first attrs is_inline
168168

169-
let is_await : attr -> bool =
170-
fun ({txt}, _) -> txt = "await" || txt = "res.await"
171-
172-
let is_async : attr -> bool =
173-
fun ({txt}, _) -> txt = "async" || txt = "res.async"
174-
175-
let has_await_payload (attrs : t) = Ext_list.find_first attrs is_await
176-
let has_async_payload (attrs : t) = Ext_list.find_first attrs is_async
169+
let has_await_payload (attrs : t) = Ext_list.find_first attrs Ast_await.is_await
170+
let has_async_payload (attrs : t) = Ext_list.find_first attrs Ast_async.is_async
177171

178172
type derive_attr = {bs_deriving: Ast_payload.action list option} [@@unboxed]
179173

jscomp/ml/ast_async.ml

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
let is_async : Parsetree.attribute -> bool =
2+
fun ({txt}, _) -> txt = "async" || txt = "res.async"
3+
14
let add_promise_type ?(loc = Location.none) ~async
25
(result : Parsetree.expression) =
36
if async then

jscomp/ml/ast_await.ml

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
let is_await : Parsetree.attribute -> bool =
2+
fun ({txt}, _) -> txt = "await" || txt = "res.await"
3+
14
let create_await_expression (e : Parsetree.expression) =
25
let loc = e.pexp_loc in
36
let unsafe_await =

jscomp/syntax/src/react_jsx_common.ml

-3
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,6 @@ let removeArity binding =
6464
in
6565
{binding with pvb_expr = removeArityRecord binding.pvb_expr}
6666

67-
let is_async : Parsetree.attribute -> bool =
68-
fun ({txt}, _) -> txt = "async" || txt = "res.async"
69-
7067
let async_component ~async expr =
7168
if async then
7269
let open Ast_helper in

jscomp/syntax/src/reactjs_jsx_v4.ml

+1-2
Original file line numberDiff line numberDiff line change
@@ -910,8 +910,7 @@ let mapBinding ~config ~emptyLoc ~pstr_loc ~fileName ~recFlag binding =
910910
modifiedBinding ~bindingLoc ~bindingPatLoc ~fnName binding
911911
in
912912
let isAsync =
913-
Ext_list.find_first binding.pvb_expr.pexp_attributes
914-
React_jsx_common.is_async
913+
Ext_list.find_first binding.pvb_expr.pexp_attributes Ast_async.is_async
915914
|> Option.is_some
916915
in
917916
(* do stuff here! *)

0 commit comments

Comments
 (0)