Skip to content

Commit

Permalink
Merge pull request #154 from gasche/4.05-support
Browse files Browse the repository at this point in the history
make ppx_deriving 4.1 build under 4.05
  • Loading branch information
gasche authored Oct 30, 2017
2 parents 6b75b9e + 9b449ea commit 4792500
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions opam
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ depends: [
"ocamlbuild" {build}
"ocamlfind" {build & >= "1.6.0"}
"cppo" {build}
"cppo_ocamlbuild" {build}
"ppx_tools" {>= "4.02.3"}
"result"
"ounit" {test}
Expand Down
8 changes: 8 additions & 0 deletions src/ppx_deriving.cppo.ml
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,9 @@ let free_vars_in_core_type typ =
List.map free_in xs |> List.concat
| { ptyp_desc = Ptyp_alias (x, name) } -> [name] @ free_in x
| { ptyp_desc = Ptyp_poly (bound, x) } ->
#if OCAML_VERSION >= (4, 05, 0)
let bound = List.map (fun y -> y.txt) bound in
#endif
List.filter (fun y -> not (List.mem y bound)) (free_in x)
| { ptyp_desc = Ptyp_variant (rows, _, _) } ->
List.map (
Expand Down Expand Up @@ -419,6 +422,11 @@ let binop_reduce x a b =

let strong_type_of_type ty =
let free_vars = free_vars_in_core_type ty in
#if OCAML_VERSION >= (4, 05, 0)
(* give the location of the whole type to the introduced variables *)
let loc = { ty.ptyp_loc with loc_ghost = true } in
let free_vars = List.map (fun v -> mkloc v loc) free_vars in
#endif
Typ.force_poly @@ Typ.poly free_vars ty

type deriver_options =
Expand Down

0 comments on commit 4792500

Please sign in to comment.