Skip to content

Commit 88f614d

Browse files
committed
Remove the arity parameter of type function$.
1 parent d14b9a4 commit 88f614d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+268
-411
lines changed

analysis/src/CompletionBackEnd.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1362,7 +1362,7 @@ let rec completeTypedValue ?(typeArgContext : typeArgContext option) ~rawOpens
13621362
| Tlink t1
13631363
| Tsubst t1
13641364
| Tpoly (t1, [])
1365-
| Tconstr (Pident {name = "function$"}, [t1; _], _) ->
1365+
| Tconstr (Pident {name = "function$"}, [t1], _) ->
13661366
fnReturnsTypeT t1
13671367
| Tarrow _ -> (
13681368
match TypeUtils.extractFunctionType ~env ~package:full.package t with

analysis/src/CompletionJsx.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ let getJsxLabels ~componentPath ~findTypeOfValue ~package =
238238
| Tlink t1
239239
| Tsubst t1
240240
| Tpoly (t1, [])
241-
| Tconstr (Pident {name = "function$"}, [t1; _], _) ->
241+
| Tconstr (Pident {name = "function$"}, [t1], _) ->
242242
getLabels t1
243243
| Tconstr (p, [propsType], _) when Path.name p = "React.component" -> (
244244
let rec getPropsType (t : Types.type_expr) =

analysis/src/CreateInterface.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ let printSignature ~extractor ~signature =
123123
Ctype.newconstr (Pdot (Pident (Ident.create "React"), "element", 0)) []
124124
in
125125
match typ.desc with
126-
| Tconstr (Pident {name = "function$"}, [typ; _], _) -> getComponentType typ
126+
| Tconstr (Pident {name = "function$"}, [typ], _) -> getComponentType typ
127127
| Tarrow
128128
(_, {desc = Tconstr (Path.Pident propsId, typeArgs, _)}, retType, _, _)
129129
when Ident.name propsId = "props" ->

analysis/src/SignatureHelp.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ let extractParameters ~signature ~typeStrForParser ~labelPrefixLen =
118118
ptyp_desc =
119119
Ptyp_constr
120120
( {txt = Lident "function$"},
121-
[({ptyp_desc = Ptyp_arrow _} as expr); _] );
121+
[({ptyp_desc = Ptyp_arrow _} as expr)] );
122122
};
123123
};
124124
} );

analysis/src/TypeUtils.ml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ let findTypeViaLoc ~full ~debug (loc : Location.t) =
3636

3737
let rec pathFromTypeExpr (t : Types.type_expr) =
3838
match t.desc with
39-
| Tconstr (Pident {name = "function$"}, [t; _], _) -> pathFromTypeExpr t
39+
| Tconstr (Pident {name = "function$"}, [t], _) -> pathFromTypeExpr t
4040
| Tconstr (path, _typeArgs, _)
4141
| Tlink {desc = Tconstr (path, _typeArgs, _)}
4242
| Tsubst {desc = Tconstr (path, _typeArgs, _)}
@@ -243,7 +243,7 @@ let rec extractFunctionType ~env ~package typ =
243243
match t.desc with
244244
| Tlink t1 | Tsubst t1 | Tpoly (t1, []) -> loop ~env acc t1
245245
| Tarrow (label, tArg, tRet, _, _) -> loop ~env ((label, tArg) :: acc) tRet
246-
| Tconstr (Pident {name = "function$"}, [t; _], _) ->
246+
| Tconstr (Pident {name = "function$"}, [t], _) ->
247247
extractFunctionType ~env ~package t
248248
| Tconstr (path, typeArgs, _) -> (
249249
match References.digConstructor ~env ~package path with
@@ -283,7 +283,7 @@ let rec extractFunctionType2 ?typeArgContext ~env ~package typ =
283283
| Tlink t1 | Tsubst t1 | Tpoly (t1, []) -> loop ?typeArgContext ~env acc t1
284284
| Tarrow (label, tArg, tRet, _, _) ->
285285
loop ?typeArgContext ~env ((label, tArg) :: acc) tRet
286-
| Tconstr (Pident {name = "function$"}, [t; _], _) ->
286+
| Tconstr (Pident {name = "function$"}, [t], _) ->
287287
extractFunctionType2 ?typeArgContext ~env ~package t
288288
| Tconstr (path, typeArgs, _) -> (
289289
match References.digConstructor ~env ~package path with
@@ -334,7 +334,7 @@ let rec extractType ?(printOpeningDebug = true)
334334
Some (Tstring env, typeArgContext)
335335
| Tconstr (Path.Pident {name = "exn"}, [], _) ->
336336
Some (Texn env, typeArgContext)
337-
| Tconstr (Pident {name = "function$"}, [t; _], _) -> (
337+
| Tconstr (Pident {name = "function$"}, [t], _) -> (
338338
match extractFunctionType2 ?typeArgContext t ~env ~package with
339339
| args, tRet, typeArgContext when args <> [] ->
340340
Some
@@ -910,7 +910,7 @@ let getArgs ~env (t : Types.type_expr) ~full =
910910
| Tlink t1
911911
| Tsubst t1
912912
| Tpoly (t1, [])
913-
| Tconstr (Pident {name = "function$"}, [t1; _], _) ->
913+
| Tconstr (Pident {name = "function$"}, [t1], _) ->
914914
getArgsLoop ~full ~env ~currentArgumentPosition t1
915915
| Tarrow (Labelled l, tArg, tRet, _, _) ->
916916
(SharedTypes.Completable.Labelled l, tArg)

compiler/frontend/ast_core_type_class_type.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ let typ_mapper (self : Bs_ast_mapper.mapper) (ty : Parsetree.core_type) =
7373
| Ptyp_constr
7474
(* function$<...> is re-wrapped around only in case Nothing below *)
7575
( {txt = Lident "function$"},
76-
[{ptyp_desc = Ptyp_arrow (label, args, body, _)}; _] ) );
76+
[{ptyp_desc = Ptyp_arrow (label, args, body, _)}] ) );
7777
(* let it go without regard label names,
7878
it will report error later when the label is not empty
7979
*)

compiler/frontend/ast_external_process.ml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -935,21 +935,16 @@ let handle_attributes (loc : Bs_loc.t) (type_annotation : Parsetree.core_type)
935935
let prim_name_with_source = {name = prim_name; source = External} in
936936
let type_annotation, build_uncurried_type =
937937
match type_annotation.ptyp_desc with
938-
| Ptyp_constr (({txt = Lident "function$"; _} as lid), [t; arity_]) ->
938+
| Ptyp_constr (({txt = Lident "function$"; _} as lid), [t]) ->
939939
( t,
940940
fun ~arity (x : Parsetree.core_type) ->
941-
let t_arity =
942-
match arity with
943-
| Some arity -> Ast_uncurried.arity_type ~loc arity
944-
| None -> arity_
945-
in
946941
let x =
947942
match x.ptyp_desc with
948943
| Ptyp_arrow (l, t1, t2, _) ->
949944
{x with ptyp_desc = Ptyp_arrow (l, t1, t2, arity)}
950945
| _ -> x
951946
in
952-
{x with Parsetree.ptyp_desc = Ptyp_constr (lid, [x; t_arity])} )
947+
{x with Parsetree.ptyp_desc = Ptyp_constr (lid, [x])} )
953948
| _ -> (type_annotation, fun ~arity:_ x -> x)
954949
in
955950
let result_type, arg_types_ty =

compiler/gentype/TranslateTypeExprFromTypes.ml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,7 @@ let translate_constr ~config ~params_translation ~(path : Path.t) ~type_env =
231231
{param_translation with type_ = Promise param_translation.type_}
232232
| (["Js"; "Dict"; "t"] | ["Dict"; "t"] | ["dict"]), [param_translation] ->
233233
{param_translation with type_ = Dict param_translation.type_}
234-
| ["function$"], [arg; _arity] ->
235-
{dependencies = arg.dependencies; type_ = arg.type_}
234+
| ["function$"], [arg] -> {dependencies = arg.dependencies; type_ = arg.type_}
236235
| _ -> default_case ()
237236

238237
type process_variant = {

compiler/ml/ast_mapper_from0.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ module T = struct
123123
let fun_t =
124124
{fun_t with ptyp_desc = Ptyp_arrow (lbl, t1, t2, Some arity)}
125125
in
126-
{typ0 with ptyp_desc = Ptyp_constr (lid, [fun_t; t_arity])}
126+
{typ0 with ptyp_desc = Ptyp_constr (lid, [fun_t])}
127127
| _ -> typ0)
128128
| Ptyp_object (l, o) ->
129129
object_ ~loc ~attrs (List.map (object_field sub) l) o

compiler/ml/ast_mapper_to0.ml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,17 @@ module T = struct
101101
| Ptyp_arrow (lab, t1, t2, _) ->
102102
arrow ~loc ~attrs lab (sub.typ sub t1) (sub.typ sub t2)
103103
| Ptyp_tuple tyl -> tuple ~loc ~attrs (List.map (sub.typ sub) tyl)
104+
| Ptyp_constr
105+
( ({txt = Lident "function$"} as lid),
106+
[({ptyp_desc = Ptyp_arrow (_, _, _, Some arity)} as t_arg)] ) ->
107+
let encode_arity_string arity = "Has_arity" ^ string_of_int arity in
108+
let arity_type ~loc arity =
109+
Ast_helper0.Typ.variant ~loc
110+
[Rtag ({txt = encode_arity_string arity; loc}, [], true, [])]
111+
Closed None
112+
in
113+
constr ~loc ~attrs (map_loc sub lid)
114+
[sub.typ sub t_arg; arity_type ~loc:Location.none arity]
104115
| Ptyp_constr (lid, tl) ->
105116
constr ~loc ~attrs (map_loc sub lid) (List.map (sub.typ sub) tl)
106117
| Ptyp_object (l, o) ->

0 commit comments

Comments
 (0)