Skip to content

Commit 07c6fb7

Browse files
committed
Also adapt arrow in typedtree.
1 parent 1f11c41 commit 07c6fb7

File tree

8 files changed

+23
-17
lines changed

8 files changed

+23
-17
lines changed

compiler/gentype/TranslateCoreType.ml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ let rec translate_arrow_type ~config ~type_vars_gen
5252
~no_function_return_dependencies ~type_env ~rev_arg_deps ~rev_args
5353
(core_type : Typedtree.core_type) =
5454
match core_type.ctyp_desc with
55-
| Ttyp_arrow (Nolabel, core_type1, core_type2, arity)
55+
| Ttyp_arrow ({lbl = Nolabel; typ = core_type1}, core_type2, arity)
5656
when arity = None || rev_args = [] ->
5757
let {dependencies; type_} =
5858
core_type1 |> fun __x ->
@@ -64,7 +64,9 @@ let rec translate_arrow_type ~config ~type_vars_gen
6464
~no_function_return_dependencies ~type_env ~rev_arg_deps:next_rev_deps
6565
~rev_args:((Nolabel, type_) :: rev_args)
6666
| Ttyp_arrow
67-
(((Labelled lbl | Optional lbl) as label), core_type1, core_type2, arity)
67+
( {lbl = (Labelled lbl | Optional lbl) as label; typ = core_type1},
68+
core_type2,
69+
arity )
6870
when arity = None || rev_args = [] -> (
6971
let as_label =
7072
match core_type.ctyp_attributes |> Annotation.get_gentype_as_renaming with

compiler/ml/printtyped.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,11 @@ let rec core_type i ppf x =
149149
match x.ctyp_desc with
150150
| Ttyp_any -> line i ppf "Ttyp_any\n"
151151
| Ttyp_var s -> line i ppf "Ttyp_var %s\n" s
152-
| Ttyp_arrow (l, ct1, ct2, _) ->
152+
| Ttyp_arrow (arg, ret, _) ->
153153
line i ppf "Ttyp_arrow\n";
154-
arg_label i ppf l;
155-
core_type i ppf ct1;
156-
core_type i ppf ct2
154+
arg_label i ppf arg.lbl;
155+
core_type i ppf arg.typ;
156+
core_type i ppf ret
157157
| Ttyp_tuple l ->
158158
line i ppf "Ttyp_tuple\n";
159159
list i core_type ppf l

compiler/ml/tast_iterator.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,9 +284,9 @@ let typ sub {ctyp_desc; ctyp_env; _} =
284284
match ctyp_desc with
285285
| Ttyp_any -> ()
286286
| Ttyp_var _ -> ()
287-
| Ttyp_arrow (_, ct1, ct2, _) ->
288-
sub.typ sub ct1;
289-
sub.typ sub ct2
287+
| Ttyp_arrow (arg, ret, _) ->
288+
sub.typ sub arg.typ;
289+
sub.typ sub ret
290290
| Ttyp_tuple list -> List.iter (sub.typ sub) list
291291
| Ttyp_constr (_, _, list) -> List.iter (sub.typ sub) list
292292
| Ttyp_object (list, _) -> List.iter (sub.object_field sub) list

compiler/ml/tast_mapper.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,8 +359,8 @@ let typ sub x =
359359
let ctyp_desc =
360360
match x.ctyp_desc with
361361
| (Ttyp_any | Ttyp_var _) as d -> d
362-
| Ttyp_arrow (label, ct1, ct2, arity) ->
363-
Ttyp_arrow (label, sub.typ sub ct1, sub.typ sub ct2, arity)
362+
| Ttyp_arrow (arg, ret, arity) ->
363+
Ttyp_arrow ({arg with typ = sub.typ sub arg.typ}, sub.typ sub ret, arity)
364364
| Ttyp_tuple list -> Ttyp_tuple (List.map (sub.typ sub) list)
365365
| Ttyp_constr (path, lid, list) ->
366366
Ttyp_constr (path, lid, List.map (sub.typ sub) list)

compiler/ml/typedtree.ml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,10 +303,12 @@ and core_type = {
303303
ctyp_attributes: attribute list;
304304
}
305305

306+
and arg = {lbl: Noloc.arg_label; typ: core_type}
307+
306308
and core_type_desc =
307309
| Ttyp_any
308310
| Ttyp_var of string
309-
| Ttyp_arrow of Noloc.arg_label * core_type * core_type * arity
311+
| Ttyp_arrow of arg * core_type * arity
310312
| Ttyp_tuple of core_type list
311313
| Ttyp_constr of Path.t * Longident.t loc * core_type list
312314
| Ttyp_object of object_field list * closed_flag

compiler/ml/typedtree.mli

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,10 +409,12 @@ and core_type = {
409409
ctyp_attributes: attributes;
410410
}
411411

412+
and arg = {lbl: Noloc.arg_label; typ: core_type}
413+
412414
and core_type_desc =
413415
| Ttyp_any
414416
| Ttyp_var of string
415-
| Ttyp_arrow of Noloc.arg_label * core_type * core_type * arity
417+
| Ttyp_arrow of arg * core_type * arity
416418
| Ttyp_tuple of core_type list
417419
| Ttyp_constr of Path.t * Longident.t loc * core_type list
418420
| Ttyp_object of object_field list * closed_flag

compiler/ml/typedtreeIter.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -375,9 +375,9 @@ end = struct
375375
(match ct.ctyp_desc with
376376
| Ttyp_any -> ()
377377
| Ttyp_var _ -> ()
378-
| Ttyp_arrow (_label, ct1, ct2, _) ->
379-
iter_core_type ct1;
380-
iter_core_type ct2
378+
| Ttyp_arrow (arg, ret, _) ->
379+
iter_core_type arg.typ;
380+
iter_core_type ret
381381
| Ttyp_tuple list -> List.iter iter_core_type list
382382
| Ttyp_constr (_path, _, list) -> List.iter iter_core_type list
383383
| Ttyp_object (list, _o) -> List.iter iter_object_field list

compiler/ml/typetexp.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ and transl_type_aux env policy styp =
329329
else ty1
330330
in
331331
let ty = newty (Tarrow (lbl, ty1, cty2.ctyp_type, Cok, arity)) in
332-
ctyp (Ttyp_arrow (lbl, cty1, cty2, arity)) ty
332+
ctyp (Ttyp_arrow ({lbl; typ = cty1}, cty2, arity)) ty
333333
| Ptyp_tuple stl ->
334334
assert (List.length stl >= 2);
335335
let ctys = List.map (transl_type env policy) stl in

0 commit comments

Comments
 (0)