Skip to content

Commit b5e0f67

Browse files
committed
support type params
1 parent 95391e5 commit b5e0f67

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

compiler/syntax/src/res_core.ml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ let mk_loc start_loc end_loc =
1111
Location.{loc_start = start_loc; loc_end = end_loc; loc_ghost = false}
1212

1313
type inline_types_context = {
14-
mutable found_inline_types: (string * Warnings.loc * Parsetree.type_kind) list;
14+
mutable found_inline_types:
15+
(string * Warnings.loc * Parsetree.type_kind) list;
16+
params: (Parsetree.core_type * Asttypes.variance) list;
1517
}
1618

1719
module Recover = struct
@@ -4212,7 +4214,7 @@ and parse_record_or_object_type ?current_type_name_path ?inline_types_context
42124214
:: inline_types_context.found_inline_types;
42134215

42144216
let lid = Location.mkloc (Longident.Lident inline_type_name) loc in
4215-
Ast_helper.Typ.constr ~loc lid []
4217+
Ast_helper.Typ.constr ~loc lid (inline_types_context.params |> List.map fst)
42164218
| _ ->
42174219
let () =
42184220
match p.token with
@@ -5599,7 +5601,7 @@ and parse_type_definition_or_extension ~attrs p =
55995601
|> Diagnostics.message)
56005602
in
56015603
let current_type_name_path = Longident.flatten name.txt in
5602-
let inline_types_context = {found_inline_types = []} in
5604+
let inline_types_context = {found_inline_types = []; params} in
56035605
let type_defs =
56045606
parse_type_definitions ~inline_types_context ~current_type_name_path
56055607
~attrs ~name ~params ~start_pos p
@@ -5612,7 +5614,7 @@ and parse_type_definition_or_extension ~attrs p =
56125614
let inline_types =
56135615
inline_types_context.found_inline_types
56145616
|> List.map (fun (inline_type_name, loc, kind) ->
5615-
Ast_helper.Type.mk
5617+
Ast_helper.Type.mk ~params
56165618
~attrs:[(Location.mknoloc "res.inlineRecordDefinition", PStr [])]
56175619
~loc ~kind
56185620
{name with txt = inline_type_name})

compiler/syntax/src/res_printer.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1722,7 +1722,7 @@ and print_typ_expr ?inline_record_definitions ~(state : State.t)
17221722
| Ptyp_object (fields, open_flag) ->
17231723
print_object ~state ~inline:false fields open_flag cmt_tbl
17241724
| Ptyp_arrow {arity} -> print_arrow ~arity typ_expr
1725-
| Ptyp_constr ({txt = Lident inline_record_name}, [])
1725+
| Ptyp_constr ({txt = Lident inline_record_name}, _)
17261726
when inline_record_definitions
17271727
|> find_inline_record_definition inline_record_name
17281728
|> Option.is_some -> (

0 commit comments

Comments
 (0)