Skip to content

Commit 5a56d6d

Browse files
committed
Stop forcing subst when constructing short-paths graph
1 parent 0de1d1d commit 5a56d6d

File tree

3 files changed

+15
-20
lines changed

3 files changed

+15
-20
lines changed

src/ocaml/typing/env.ml

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5349,7 +5349,7 @@ let short_paths_class_type_desc clty =
53495349
| ns -> Subst(path, ns)
53505350
end
53515351

5352-
let short_paths_module_type_desc mty =
5352+
let short_paths_module_type_desc (mty : Subst.Lazy.module_type option) =
53535353
let open Short_paths.Desc.Module_type in
53545354
match mty with
53555355
| None | Some Mty_for_hole -> Fresh
@@ -5373,13 +5373,14 @@ let deprecated_of_alerts alerts =
53735373
let deprecated_of_attributes attrs =
53745374
deprecated_of_alerts (Builtin_attributes.alerts_of_attrs attrs)
53755375

5376-
let scrape =
5377-
(* to be filled with Mtype.scrape_alias *)
5378-
ref ((fun _env _mty -> assert false) : t -> module_type -> module_type)
5376+
let scrape_lazy =
5377+
(* to be filled with Mtype.scrape_lazy *)
5378+
ref ((fun (_env : t) (_mty : Subst.Lazy.module_type) : Subst.Lazy.module_type ->
5379+
assert false))
53795380

53805381
let rec short_paths_module_desc env mpath mty comp =
53815382
let open Short_paths.Desc.Module in
5382-
match !scrape env mty with
5383+
match !scrape_lazy env mty with
53835384
| Mty_alias path -> Alias path
53845385
| Mty_ident _ -> Fresh (Signature (lazy []))
53855386
| Mty_signature _ ->
@@ -5418,19 +5419,17 @@ and short_paths_module_components_desc env mpath comp =
54185419
in
54195420
let comps =
54205421
String.Map.fold (fun name mtda acc ->
5421-
let mtd = Subst.Lazy.force_modtype_decl mtda.mtda_declaration in
5422-
let desc = short_paths_module_type_desc mtd.mtd_type in
5423-
let depr = deprecated_of_attributes mtd.mtd_attributes in
5422+
let desc = short_paths_module_type_desc mtda.mtda_declaration.mtd_type in
5423+
let depr = deprecated_of_attributes mtda.mtda_declaration.mtd_attributes in
54245424
let item = Short_paths.Desc.Module.Module_type(name, desc, depr) in
54255425
item :: acc
54265426
) c.comp_modtypes comps
54275427
in
54285428
let comps =
54295429
String.Map.fold (fun name { mda_declaration; mda_components; _ } acc ->
5430-
let mty = Subst.Lazy.force_module_decl mda_declaration in
54315430
let mpath = Pdot(mpath, name) in
54325431
let desc =
5433-
short_paths_module_desc env mpath mty.md_type mda_components
5432+
short_paths_module_desc env mpath mda_declaration.md_type mda_components
54345433
in
54355434
let depr = deprecated_of_alerts mda_components.alerts in
54365435
let item = Short_paths.Desc.Module.Module(name, desc, depr) in
@@ -5460,6 +5459,7 @@ and short_paths_functor_components_desc env mpath comp path =
54605459
stamped_path_add f.fcomp_subst_cache path mty;
54615460
mty
54625461
in
5462+
let mty = Subst.Lazy.of_modtype mty in
54635463
let loc = Location.(in_file !input_name) in
54645464
let comps =
54655465
components_of_functor_appl ~loc ~f_comp:f env ~f_path:mpath ~arg:path
@@ -5482,16 +5482,12 @@ let short_paths_additions_desc env additions =
54825482
let depr = deprecated_of_attributes clty.clty_attributes in
54835483
Short_paths.Desc.Class_type(id, desc, source, depr) :: acc
54845484
| Module_type(id, mtd) ->
5485-
let mtd_type = Option.map Subst.Lazy.force_modtype mtd.mtd_type in
5486-
let desc = short_paths_module_type_desc mtd_type in
5485+
let desc = short_paths_module_type_desc mtd.mtd_type in
54875486
let source = Short_paths.Desc.Local in
54885487
let depr = deprecated_of_attributes mtd.mtd_attributes in
54895488
Short_paths.Desc.Module_type(id, desc, source, depr) :: acc
54905489
| Module(id, md, comps) ->
5491-
let md_type = Subst.Lazy.force_modtype md.md_type in
5492-
let desc =
5493-
short_paths_module_desc env (Pident id) md_type comps
5494-
in
5490+
let desc = short_paths_module_desc env (Pident id) md.md_type comps in
54955491
let source = Short_paths.Desc.Local in
54965492
let depr = deprecated_of_alerts comps.alerts in
54975493
Short_paths.Desc.Module(id, desc, source, depr) :: acc
@@ -5516,9 +5512,8 @@ let short_paths_additions_desc env additions =
55165512
Short_paths.Desc.Class_type(id, desc, source, depr) :: acc)
55175513
decls acc
55185514
| Module_type_open(root, decls) ->
5519-
let decls = NameMap.map Subst.Lazy.force_modtype_decl decls in
55205515
String.Map.fold
5521-
(fun name mtd acc ->
5516+
(fun name (mtd : Subst.Lazy.modtype_declaration) acc ->
55225517
let id = Ident.create_local name in
55235518
let path = Pdot(root, name) in
55245519
let desc = Short_paths.Desc.Module_type.Alias path in

src/ocaml/typing/env.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,7 @@ val with_cmis : (unit -> 'a) -> 'a
754754

755755
val add_merlin_extension_module: Ident.t -> module_type -> t -> t
756756
val cleanup_functor_caches : stamp:int -> unit
757-
val scrape: (t -> module_type -> module_type) ref
757+
val scrape_lazy: (t -> Subst.Lazy.module_type -> Subst.Lazy.module_type) ref
758758
val cleanup_usage_tables : stamp:int -> unit
759759

760760
(** This value should be filled in with [Msupport.raise_error]. [Env] cannot use this

src/ocaml/typing/mtype.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ let scrape env mty =
422422
let () =
423423
Printtyp.expand_module_type := expand ;
424424
Env.scrape_alias := scrape_alias_lazy ;
425-
Env.scrape := scrape
425+
Env.scrape_lazy := scrape_lazy
426426

427427
let find_type_of_module ~strengthen ~aliasable env path =
428428
if strengthen then

0 commit comments

Comments
 (0)