Skip to content

Commit

Permalink
Recurse for eager loading of deps
Browse files Browse the repository at this point in the history
  • Loading branch information
tjammer committed Aug 8, 2024
1 parent c7bd8aa commit 352b19e
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions lib/module.ml
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,26 @@ module Map_canon : Map_module.Map_tree = struct
(id, m)

let map_decl ~mname _ sub decl =
match decl.kind with
| Dalias (Tconstr (name, _)) -> (
match Path.rm_head name with
| Some m when not (Path.share_base mname m) ->
eagerly_load m;
(sub, decl)
| None | Some _ -> (sub, decl))
| _ -> (sub, decl)
let rec load_type = function
| Tconstr (name, _) -> (
match Path.rm_head name with
| Some m when not (Path.share_base mname m) -> eagerly_load m
| None | Some _ -> ())
| Tvar { contents = Link t } | Tfixed_array (_, t) -> load_type t
| Qvar _ | Tvar { contents = Unbound _ } -> ()
| Tfun (ps, ret, _) ->
List.iter (fun p -> load_type p.pt) ps;
load_type ret
| Ttuple ts -> List.iter load_type ts
in

(match decl.kind with
| Dalias typ -> load_type typ
| Drecord (_, fields) -> Array.iter (fun f -> load_type f.ftyp) fields
| Dvariant (_, ctors) ->
Array.iter (fun ct -> Option.map load_type ct.ctyp |> ignore) ctors
| Dabstract _ -> ());
(sub, decl)

let absolute_module_name = absolute_module_name
let map_type = Map_module.Canonize.canonize
Expand Down

0 comments on commit 352b19e

Please sign in to comment.