@@ -27,7 +27,7 @@ type ('p, 't) item =
2727 part_errors : exn list ;
2828 part_checks : Typecore .delayed_check list ;
2929 part_warnings : Warnings .state ;
30- part_index : index
30+ part_index : index lazy_t
3131 }
3232
3333type typedtree =
@@ -110,7 +110,9 @@ let[@tail_mod_cons] rec type_structure config caught env index sg = function
110110 let items, sg', part_env =
111111 Typemod. merlin_type_structure env sg [ parsetree_item ]
112112 in
113- let part_index = ! index_items index config (`Impl items.str_items) in
113+ let part_index =
114+ lazy (! index_items (Lazy. force index) config (`Impl items.str_items))
115+ in
114116 let typedtree_items =
115117 (items.Typedtree. str_items, items.Typedtree. str_type)
116118 in
@@ -146,7 +148,9 @@ let[@tail_mod_cons] rec type_signature config caught env index sg psg_modalities
146148 [ parsetree_item ])
147149 in
148150 let part_rev_sg = List. rev_append sig_type sg in
149- let part_index = ! index_items index config (`Intf sig_items) in
151+ let part_index =
152+ lazy (! index_items (Lazy. force index) config (`Intf sig_items))
153+ in
150154 let item =
151155 { parsetree_item;
152156 typedtree_items = (sig_items, sig_type);
@@ -184,7 +188,7 @@ let type_implementation config caught parsetree =
184188 ident_stamp,
185189 uid_stamp,
186190 Warnings. backup () ,
187- Shape.Uid.Map. empty )
191+ lazy Shape.Uid.Map. empty )
188192 | x :: _ ->
189193 caught := x.part_errors;
190194 Typecore. delayed_checks := x.part_checks;
@@ -235,7 +239,7 @@ let type_interface config caught (parsetree : Parsetree.signature) =
235239 ident_stamp,
236240 uid_stamp,
237241 Warnings. backup () ,
238- Shape.Uid.Map. empty )
242+ lazy Shape.Uid.Map. empty )
239243 | x :: _ ->
240244 caught := x.part_errors;
241245 Typecore. delayed_checks := x.part_checks;
@@ -360,7 +364,7 @@ let get_index t =
360364 let of_items items =
361365 List. last items
362366 |> Option. value_map ~default: Shape.Uid.Map. empty
363- ~f: (fun { part_index; _ } -> part_index)
367+ ~f: (fun { part_index; _ } -> Lazy. force part_index)
364368 in
365369 match t.typedtree with
366370 | Implementation_items items -> of_items items
0 commit comments