Skip to content

Commit be7ea6e

Browse files
committed
Remove last use of core_type_is_uncurried_fun.
1 parent 7b2b633 commit be7ea6e

File tree

4 files changed

+9
-24
lines changed

4 files changed

+9
-24
lines changed

compiler/frontend/ast_core_type.ml

+4-4
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,10 @@ let get_uncurry_arity (ty : t) =
124124
| _ -> None
125125

126126
let get_curry_arity (ty : t) =
127-
if Ast_uncurried.core_type_is_uncurried_fun ty then
128-
let arity, _ = Ast_uncurried.core_type_extract_uncurried_fun ty in
129-
arity
130-
else get_uncurry_arity_aux ty 0
127+
match Ast_uncurried.core_type_remove_function_dollar ty with
128+
| {ptyp_desc = Ptyp_arrow (_, _, _, Some arity)} -> arity
129+
| _ -> get_uncurry_arity_aux ty 0
130+
131131
let is_arity_one ty = get_curry_arity ty = 1
132132

133133
type param_type = {

compiler/ml/ast_uncurried.ml

-14
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,6 @@ let expr_extract_uncurried_fun (expr : Parsetree.expression) =
2828
| Pexp_fun (_, _, _, _, Some _) -> expr
2929
| _ -> assert false
3030

31-
let core_type_is_uncurried_fun (typ : Parsetree.core_type) =
32-
match typ.ptyp_desc with
33-
| Ptyp_constr ({txt = Lident "function$"}, [{ptyp_desc = Ptyp_arrow _}]) ->
34-
true
35-
| _ -> false
36-
37-
let core_type_extract_uncurried_fun (typ : Parsetree.core_type) =
38-
match typ.ptyp_desc with
39-
| Ptyp_constr
40-
( {txt = Lident "function$"},
41-
[({ptyp_desc = Ptyp_arrow (_, _, _, Some arity)} as t_arg)] ) ->
42-
(arity, t_arg)
43-
| _ -> assert false
44-
4531
(* Typed AST *)
4632

4733
let tarrow_to_arity (t_arity : Types.type_expr) =

compiler/ml/ast_untagged_variants.ml

+1-6
Original file line numberDiff line numberDiff line change
@@ -186,14 +186,9 @@ let type_to_instanceof_backed_obj (t : Types.type_expr) =
186186
| _ -> None)
187187
| _ -> None
188188

189-
let remove_function_dollar (typ : Types.type_expr) =
190-
match typ.desc with
191-
| Tconstr (Pident {name = "function$"}, [t], _) -> t
192-
| _ -> typ
193-
194189
let get_block_type_from_typ ~env (t : Types.type_expr) : block_type option =
195190
let t = !expand_head env t in
196-
let t = remove_function_dollar t in
191+
let t = Tmp_uncurried.remove_function_dollar t in
197192
match t with
198193
| {desc = Tconstr (path, _, _)} when Path.same path Predef.path_string ->
199194
Some StringType

compiler/ml/tmp_uncurried.ml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
let remove_function_dollar (typ : Types.type_expr) =
2+
match typ.desc with
3+
| Tconstr (Pident {name = "function$"}, [t], _) -> t
4+
| _ -> typ

0 commit comments

Comments
 (0)