File tree Expand file tree Collapse file tree 4 files changed +21
-4
lines changed
test/encoding/504/migrations Expand file tree Collapse file tree 4 files changed +21
-4
lines changed Original file line number Diff line number Diff line change @@ -406,15 +406,23 @@ module To_503 = struct
406406 in
407407 Psig_extension (ext, [] )
408408
409+ let encode_bivariant_psig_typesubst ~loc tds =
410+ let loc = { loc with Location. loc_ghost = true } in
411+ let ext =
412+ ( { txt = Ext_name. bivariant_psig; loc },
413+ PSig [ { psig_loc = loc; psig_desc = Psig_typesubst tds } ] )
414+ in
415+ Psig_extension (ext, [] )
416+
409417 let decode_bivariant_pstr ~loc payload =
410418 match payload with
411419 | PStr [ { pstr_desc = Pstr_type _ as x; _ } ] -> x
412420 | _ -> invalid_encoding ~loc " bivariant structure_item"
413421
414422 let decode_bivariant_psig ~loc payload =
415423 match payload with
416- | PSig [ { psig_desc = Psig_type _ as x; _ } ] -> x
417- | _ -> invalid_encoding ~loc " bivariant structure_item "
424+ | PSig [ { psig_desc = ( Psig_type _ | Psig_typesubst _ ) as x ; _ } ] -> x
425+ | _ -> invalid_encoding ~loc " bivariant signature_item "
418426end
419427
420428module To_502 = struct
Original file line number Diff line number Diff line change @@ -43,6 +43,9 @@ module To_503 : sig
4343 val encode_bivariant_psig_type :
4444 loc :Location .t -> rec_flag -> type_declaration list -> signature_item_desc
4545
46+ val encode_bivariant_psig_typesubst :
47+ loc :Location .t -> type_declaration list -> signature_item_desc
48+
4649 val decode_bivariant_pstr : loc :Location .t -> payload -> structure_item_desc
4750 val decode_bivariant_psig : loc :Location .t -> payload -> signature_item_desc
4851end
Original file line number Diff line number Diff line change @@ -838,8 +838,11 @@ and copy_signature_item_desc_with_loc ~loc :
838838 | tds -> Ast_503.Parsetree. Psig_type (rec_flag, tds)
839839 | exception Bivariant_param. Type_decl_list tds ->
840840 Encoding_504.To_503. encode_bivariant_psig_type ~loc rec_flag tds)
841- | Ast_504.Parsetree. Psig_typesubst x0 ->
842- Ast_503.Parsetree. Psig_typesubst (List. map copy_type_declaration x0)
841+ | Ast_504.Parsetree. Psig_typesubst x0 -> (
842+ match copy_type_declaration_list x0 with
843+ | tds -> Ast_503.Parsetree. Psig_typesubst tds
844+ | exception Bivariant_param. Type_decl_list tds ->
845+ Encoding_504.To_503. encode_bivariant_psig_typesubst ~loc tds)
843846 | Ast_504.Parsetree. Psig_typext x0 ->
844847 Ast_503.Parsetree. Psig_typext (copy_type_extension x0)
845848 | Ast_504.Parsetree. Psig_exception x0 ->
Original file line number Diff line number Diff line change @@ -60,10 +60,13 @@ Bivariant are also correctly handled in a signature context:
6060
6161 $ cat > bivariant.mli << EOF
6262 > type +-' a t
63+ > type + -' a u := ' a v
6364 > EOF
6465
6566 $ ./ id_driver. exe bivariant. mli
6667 [%% ppxlib. migration. bivariant_sig_item_5_4 : type ' a t]
68+ [%%ppxlib.migration.bivariant_sig_item_5_4 : type ' a u := ' a v]
6769
6870 $ ./id_driver.exe bivariant.mli --use-compiler-pp
6971 type +-' a t
72+ type + -' a u := ' a v
You can’t perform that action at this time.
0 commit comments