@@ -18,6 +18,14 @@ let init () =
1818 let core_type =
1919 Ast_derive_util. core_type_of_type_declaration tdcl
2020 in
21+ let gentype_attrs =
22+ match
23+ Ext_list. exists core_type.ptyp_attributes
24+ Ast_attributes. is_gentype
25+ with
26+ | true -> Some [Ast_attributes. gentype]
27+ | false -> None
28+ in
2129 match tdcl.ptype_kind with
2230 | Ptype_record label_declarations ->
2331 Ext_list. map label_declarations
@@ -26,7 +34,7 @@ let init () =
2634 Parsetree.label_declaration )
2735 ->
2836 let txt = " param" in
29- Ast_comb. single_non_rec_value pld_name
37+ Ast_comb. single_non_rec_value ?attrs:gentype_attrs pld_name
3038 (Ast_compatible. fun_
3139 (Pat. constraint_ (Pat. var {txt; loc}) core_type)
3240 (Exp. field
@@ -57,7 +65,7 @@ let init () =
5765 | None -> core_type
5866 | Some x -> x
5967 in
60- Ast_comb. single_non_rec_value
68+ Ast_comb. single_non_rec_value ?attrs:gentype_attrs
6169 {loc; txt = little_con_name}
6270 (if arity = 0 then
6371 (* TODO: add a prefix, better inter-op with FFI *)
@@ -99,10 +107,18 @@ let init () =
99107 let core_type =
100108 Ast_derive_util. core_type_of_type_declaration tdcl
101109 in
110+ let gentype_attrs =
111+ match
112+ Ext_list. exists core_type.ptyp_attributes
113+ Ast_attributes. is_gentype
114+ with
115+ | true -> Some [Ast_attributes. gentype]
116+ | false -> None
117+ in
102118 match tdcl.ptype_kind with
103119 | Ptype_record label_declarations ->
104120 Ext_list. map label_declarations (fun {pld_name; pld_type} ->
105- Ast_comb. single_non_rec_val pld_name
121+ Ast_comb. single_non_rec_val ?attrs:gentype_attrs pld_name
106122 (Ast_compatible. arrow core_type pld_type))
107123 | Ptype_variant constructor_declarations ->
108124 Ext_list. map constructor_declarations
@@ -124,7 +140,7 @@ let init () =
124140 | Some x -> x
125141 | None -> core_type
126142 in
127- Ast_comb. single_non_rec_val
143+ Ast_comb. single_non_rec_val ?attrs:gentype_attrs
128144 {loc; txt = Ext_string. uncapitalize_ascii con_name}
129145 (Ext_list. fold_right pcd_args annotate_type (fun x acc ->
130146 Ast_compatible. arrow x acc)))
0 commit comments