Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to ppxlib 0.15.0 #235

Merged
merged 1 commit into from
Oct 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ppx_deriving.opam
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ depends: [
"dune" {>= "1.6.3"}
"cppo" {build}
"ocamlfind"
"ocaml-migrate-parsetree"
"ocaml-migrate-parsetree" {< "2.0.0"}
"ppx_derivers"
"ppxlib" {>= "0.9.0" & < "0.14.0"}
"ppxlib" {>= "0.9.0" & < "0.16.0"}
"result"
"ounit" {with-test}
]
Expand Down
32 changes: 16 additions & 16 deletions src/api/ppx_deriving.cppo.ml
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ let rec remove_pervasive_lid = function
let remove_pervasives ~deriver typ =
if attr_nobuiltin ~deriver typ.ptyp_attributes then typ
else
let open Migrate_parsetree.OCaml_408.Ast.Ast_mapper in
let open Migrate_parsetree.OCaml_410.Ast.Ast_mapper in
let map_typ mapper typ = match typ.ptyp_desc with
| Ptyp_constr (lid, l) ->
let lid = {lid with txt = remove_pervasive_lid lid.txt} in
Expand Down Expand Up @@ -672,41 +672,41 @@ module Ast_mapper = Migrate_parsetree.OCaml_current.Ast.Ast_mapper

module Ast_helper_current = Migrate_parsetree.OCaml_current.Ast.Ast_helper

module OCaml_408_of_current =
module OCaml_410_of_current =
Migrate_parsetree.Convert (Migrate_parsetree.OCaml_current)
(Migrate_parsetree.OCaml_408)
(Migrate_parsetree.OCaml_410)

module OCaml_current_of_408 =
Migrate_parsetree.Convert (Migrate_parsetree.OCaml_408)
module OCaml_current_of_410 =
Migrate_parsetree.Convert (Migrate_parsetree.OCaml_410)
(Migrate_parsetree.OCaml_current)

let copy_deriver f typ =
OCaml_current_of_408.copy_expression
(f (OCaml_408_of_current.copy_core_type typ))
OCaml_current_of_410.copy_expression
(f (OCaml_410_of_current.copy_core_type typ))

let copy_attributes attrs =
(OCaml_408_of_current.copy_core_type
(OCaml_410_of_current.copy_core_type
(Ast_helper_current.Typ.any ~attrs ()))
.ptyp_attributes

let copy_structure_item item =
match OCaml_408_of_current.copy_structure [item] with
match OCaml_410_of_current.copy_structure [item] with
| [item] -> item
| _ -> assert false

let copy_signature_item item =
match OCaml_408_of_current.copy_signature [item] with
match OCaml_410_of_current.copy_signature [item] with
| [item] -> item
| _ -> assert false

let has_attr_current name attributes =
has_attr name (copy_attributes attributes)

let copy_derive derive item f =
OCaml_current_of_408.copy_structure (derive (copy_structure_item item) f)
OCaml_current_of_410.copy_structure (derive (copy_structure_item item) f)

let copy_derive_sig derive item f =
OCaml_current_of_408.copy_signature (derive (copy_signature_item item) f)
OCaml_current_of_410.copy_signature (derive (copy_signature_item item) f)

let copy_module_type_declaration modtype =
match copy_structure_item (Ast_helper_current.Str.modtype modtype) with
Expand Down Expand Up @@ -765,13 +765,13 @@ let mapper =
let derived =
Ast_helper.with_default_loc pstr_loc (fun () ->
let typ_decls =
List.map OCaml_408_of_current.copy_type_declaration typ_decls in
List.map OCaml_410_of_current.copy_type_declaration typ_decls in
copy_derive (derive_type_decl module_nesting typ_decls pstr_loc) item
(fun deriver -> deriver.type_decl_str))
in derived @ mapper.Ast_mapper.structure mapper rest
| { pstr_desc = Pstr_typext typ_ext; pstr_loc } as item :: rest when
has_attr_current "deriving" typ_ext.ptyext_attributes ->
let typ_ext = OCaml_408_of_current.copy_type_extension typ_ext in
let typ_ext = OCaml_410_of_current.copy_type_extension typ_ext in
let derived =
Ast_helper.with_default_loc pstr_loc (fun () ->
copy_derive (derive_type_ext module_nesting typ_ext pstr_loc) item
Expand Down Expand Up @@ -809,7 +809,7 @@ let mapper =
List.exists (fun ty -> has_attr_current "deriving" ty.ptype_attributes)
typ_decls ->
let typ_decls =
List.map OCaml_408_of_current.copy_type_declaration typ_decls in
List.map OCaml_410_of_current.copy_type_declaration typ_decls in
let derived =
Ast_helper.with_default_loc psig_loc (fun () ->
copy_derive_sig
Expand All @@ -818,7 +818,7 @@ let mapper =
in derived @ mapper.Ast_mapper.signature mapper rest
| { psig_desc = Psig_typext typ_ext; psig_loc } as item :: rest when
has_attr_current "deriving" typ_ext.ptyext_attributes ->
let typ_ext = OCaml_408_of_current.copy_type_extension typ_ext in
let typ_ext = OCaml_410_of_current.copy_type_extension typ_ext in
let derived =
Ast_helper.with_default_loc psig_loc (fun () ->
copy_derive_sig
Expand Down
4 changes: 2 additions & 2 deletions src/ppx_deriving_main.cppo.ml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ module Ast_mapper = Ocaml_common.Ast_mapper

module From_current =
Migrate_parsetree.Convert (Migrate_parsetree.OCaml_current)
(Migrate_parsetree.OCaml_408)
(Migrate_parsetree.OCaml_410)

module To_current =
Migrate_parsetree.Convert (Migrate_parsetree.OCaml_408)
Migrate_parsetree.Convert (Migrate_parsetree.OCaml_410)
(Migrate_parsetree.OCaml_current)

let raise_errorf = Ppx_deriving.raise_errorf
Expand Down