Skip to content

Commit b71324f

Browse files
committed
Remove function$ entirely.
1 parent b2ebcc0 commit b71324f

File tree

79 files changed

+462
-618
lines changed

Some content is hidden

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

79 files changed

+462
-618
lines changed

analysis/src/CompletionBackEnd.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1358,7 +1358,7 @@ let rec completeTypedValue ?(typeArgContext : typeArgContext option) ~rawOpens
13581358
in
13591359
(* Find all functions in the module that returns type t *)
13601360
let rec fnReturnsTypeT t =
1361-
match (Ast_uncurried.remove_function_dollar t).desc with
1361+
match t.Types.desc with
13621362
| Tlink t1 | Tsubst t1 | Tpoly (t1, []) -> fnReturnsTypeT t1
13631363
| Tarrow _ -> (
13641364
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
@@ -234,7 +234,7 @@ let getJsxLabels ~componentPath ~findTypeOfValue ~package =
234234
| _ -> []
235235
in
236236
let rec getLabels (t : Types.type_expr) =
237-
match (Ast_uncurried.remove_function_dollar t).desc with
237+
match t.desc with
238238
| Tlink t1 | Tsubst t1 | Tpoly (t1, []) -> getLabels t1
239239
| Tconstr (p, [propsType], _) when Path.name p = "React.component" -> (
240240
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
@@ -122,7 +122,7 @@ let printSignature ~extractor ~signature =
122122
let reactElement =
123123
Ctype.newconstr (Pdot (Pident (Ident.create "React"), "element", 0)) []
124124
in
125-
match (Ast_uncurried.remove_function_dollar typ).desc with
125+
match typ.desc with
126126
| Tarrow
127127
(_, {desc = Tconstr (Path.Pident propsId, typeArgs, _)}, retType, _, _)
128128
when Ident.name propsId = "props" ->

analysis/src/SignatureHelp.ml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,9 @@ let findFunctionType ~currentFile ~debug ~path ~pos =
105105
let extractParameters ~signature ~typeStrForParser ~labelPrefixLen =
106106
match signature with
107107
| [{Parsetree.psig_desc = Psig_value {pval_type = expr}}]
108-
when match
109-
(Ast_uncurried.core_type_remove_function_dollar expr).ptyp_desc
110-
with
108+
when match expr.ptyp_desc with
111109
| Ptyp_arrow _ -> true
112110
| _ -> false ->
113-
let expr = Ast_uncurried.core_type_remove_function_dollar expr in
114111
let rec extractParams expr params =
115112
match expr with
116113
| {

analysis/src/TypeUtils.ml

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

3737
let pathFromTypeExpr (t : Types.type_expr) =
38-
match (Ast_uncurried.remove_function_dollar t).desc with
38+
match t.desc with
3939
| Tconstr (path, _typeArgs, _)
4040
| Tlink {desc = Tconstr (path, _typeArgs, _)}
4141
| Tsubst {desc = Tconstr (path, _typeArgs, _)}
@@ -239,7 +239,7 @@ let rec extractObjectType ~env ~package (t : Types.type_expr) =
239239

240240
let extractFunctionType ~env ~package typ =
241241
let rec loop ~env acc (t : Types.type_expr) =
242-
match (Ast_uncurried.remove_function_dollar t).desc with
242+
match t.desc with
243243
| Tlink t1 | Tsubst t1 | Tpoly (t1, []) -> loop ~env acc t1
244244
| Tarrow (label, tArg, tRet, _, _) -> loop ~env ((label, tArg) :: acc) tRet
245245
| Tconstr (path, typeArgs, _) -> (
@@ -276,7 +276,7 @@ let maybeSetTypeArgCtx ?typeArgContextFromTypeManifest ~typeParams ~typeArgs env
276276
(* TODO(env-stuff) Maybe this could be removed entirely if we can guarantee that we don't have to look up functions from in here. *)
277277
let extractFunctionType2 ?typeArgContext ~env ~package typ =
278278
let rec loop ?typeArgContext ~env acc (t : Types.type_expr) =
279-
match (Ast_uncurried.remove_function_dollar t).desc with
279+
match t.desc with
280280
| Tlink t1 | Tsubst t1 | Tpoly (t1, []) -> loop ?typeArgContext ~env acc t1
281281
| Tarrow (label, tArg, tRet, _, _) ->
282282
loop ?typeArgContext ~env ((label, tArg) :: acc) tRet
@@ -312,7 +312,7 @@ let rec extractType ?(printOpeningDebug = true)
312312
Printf.printf "[extract_type]--> %s"
313313
(debugLogTypeArgContext typeArgContext));
314314
let instantiateType = instantiateType2 in
315-
match (Ast_uncurried.remove_function_dollar t).desc with
315+
match t.desc with
316316
| Tlink t1 | Tsubst t1 | Tpoly (t1, []) ->
317317
extractType ?typeArgContext ~printOpeningDebug:false ~env ~package t1
318318
| Tconstr (Path.Pident {name = "option"}, [payloadTypeExpr], _) ->
@@ -894,7 +894,7 @@ let rec resolveNestedPatternPath (typ : innerType) ~env ~full ~nested =
894894
let getArgs ~env (t : Types.type_expr) ~full =
895895
let rec getArgsLoop ~env (t : Types.type_expr) ~full ~currentArgumentPosition
896896
=
897-
match (Ast_uncurried.remove_function_dollar t).desc with
897+
match t.desc with
898898
| Tlink t1 | Tsubst t1 | Tpoly (t1, []) ->
899899
getArgsLoop ~full ~env ~currentArgumentPosition t1
900900
| Tarrow (Labelled l, tArg, tRet, _, _) ->

compiler/frontend/ast_core_type.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ let get_uncurry_arity (ty : t) =
124124
| _ -> None
125125

126126
let get_curry_arity (ty : t) =
127-
match Ast_uncurried.core_type_remove_function_dollar ty with
128-
| {ptyp_desc = Ptyp_arrow (_, _, _, Some arity)} -> arity
127+
match ty.ptyp_desc with
128+
| Ptyp_arrow (_, _, _, Some arity) -> arity
129129
| _ -> get_uncurry_arity_aux ty 0
130130

131131
let is_arity_one ty = get_curry_arity ty = 1
@@ -156,7 +156,7 @@ let mk_fn_type (new_arg_types_ty : param_type list) (result : t) : t =
156156
let list_of_arrow (ty : t) : t * param_type list =
157157
let rec aux (ty : t) acc =
158158
match ty.ptyp_desc with
159-
| Ptyp_arrow (label, t1, t2, _) ->
159+
| Ptyp_arrow (label, t1, t2, arity) when arity = None || acc = [] ->
160160
aux t2
161161
(({label; ty = t1; attr = ty.ptyp_attributes; loc = ty.ptyp_loc}
162162
: param_type)

compiler/frontend/ast_core_type_class_type.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ let default_typ_mapper = Bs_ast_mapper.default_mapper.typ
6666

6767
let typ_mapper (self : Bs_ast_mapper.mapper) (ty : Parsetree.core_type) =
6868
let loc = ty.ptyp_loc in
69-
match (Ast_uncurried.core_type_remove_function_dollar ty).ptyp_desc with
69+
match ty.ptyp_desc with
7070
| Ptyp_arrow (label, args, body, _)
7171
(* let it go without regard label names,
7272
it will report error later when the label is not empty

compiler/frontend/ast_derive_js_mapper.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ let app1 = Ast_compatible.app1
130130
let app2 = Ast_compatible.app2
131131

132132
let ( ->~ ) a b =
133-
Ast_uncurried.uncurried_type ~loc:Location.none ~arity:1
133+
Ast_uncurried.uncurried_type ~arity:1
134134
(Ast_compatible.arrow ~arity:(Some 1) a b)
135135

136136
let raise_when_not_found_ident =
@@ -295,7 +295,7 @@ let init () =
295295
let pat_from_js = {Asttypes.loc; txt = from_js} in
296296
let to_js_type result =
297297
Ast_comb.single_non_rec_val pat_to_js
298-
(Ast_uncurried.uncurried_type ~loc:Location.none ~arity:1
298+
(Ast_uncurried.uncurried_type ~arity:1
299299
(Ast_compatible.arrow ~arity:(Some 1) core_type result))
300300
in
301301
let new_type, new_tdcl =

compiler/frontend/ast_derive_projector.ml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,8 @@ let init () =
120120
Ext_list.flat_map tdcls handle_tdcl);
121121
signature_gen =
122122
(fun (tdcls : Parsetree.type_declaration list) _explict_nonrec ->
123-
let handle_uncurried_type_tranform ~loc ~arity t =
124-
if arity > 0 then Ast_uncurried.uncurried_type ~loc ~arity t
125-
else t
123+
let handle_uncurried_type_tranform ~arity t =
124+
if arity > 0 then Ast_uncurried.uncurried_type ~arity t else t
126125
in
127126
let handle_tdcl tdcl =
128127
let core_type =
@@ -142,8 +141,7 @@ let init () =
142141
Ast_comb.single_non_rec_val ?attrs:gentype_attrs pld_name
143142
(Ast_compatible.arrow ~arity:None core_type pld_type
144143
(*arity will alwys be 1 since these are single param functions*)
145-
|> handle_uncurried_type_tranform ~arity:1
146-
~loc:pld_name.loc))
144+
|> handle_uncurried_type_tranform ~arity:1))
147145
| Ptype_variant constructor_declarations ->
148146
Ext_list.map constructor_declarations
149147
(fun
@@ -170,7 +168,7 @@ let init () =
170168
{loc; txt = Ext_string.uncapitalize_ascii con_name}
171169
(Ext_list.fold_right pcd_args annotate_type (fun x acc ->
172170
Ast_compatible.arrow ~arity:None x acc)
173-
|> handle_uncurried_type_tranform ~arity ~loc))
171+
|> handle_uncurried_type_tranform ~arity))
174172
| Ptype_open | Ptype_abstract ->
175173
Ast_derive_util.not_applicable tdcl.ptype_loc deriving_name;
176174
[]

compiler/frontend/ast_exp_handle_external.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ let handle_ffi ~loc ~payload =
133133
match !is_function with
134134
| Some arity ->
135135
let type_ =
136-
Ast_uncurried.uncurried_type ~loc
136+
Ast_uncurried.uncurried_type
137137
~arity:(if arity = 0 then 1 else arity)
138138
(arrow ~arity)
139139
in

0 commit comments

Comments
 (0)