From 16d546100b5e18cea4fd13eb34e604d9afcd4891 Mon Sep 17 00:00:00 2001 From: Brian Campbell Date: Thu, 24 Nov 2022 18:33:34 +0000 Subject: [PATCH] Include function type annotations in the callgraph analysis Fixes #187 --- src/lib/callgraph.ml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/lib/callgraph.ml b/src/lib/callgraph.ml index 4b4bf8b83..e48159e60 100644 --- a/src/lib/callgraph.ml +++ b/src/lib/callgraph.ml @@ -303,7 +303,15 @@ let add_def_to_graph graph def = | _ -> Reporting.unreachable l __POS__ "Unexpected definition in outcome block" in - + + let scan_fundef_tannot self (FD_aux (FD_function (_, Typ_annot_opt_aux (tannotopt, _), _), _)) = + match tannotopt with + | Typ_annot_opt_none -> () + | Typ_annot_opt_some (typq, typ) -> + scan_typquant self typq; + IdSet.iter (fun typ_id -> graph := G.add_edge self (Type typ_id) !graph) (typ_ids typ) + in + begin match def with | DEF_spec (VS_aux (VS_val_spec (TypSchm_aux (TypSchm_ts (typq, (Typ_aux (Typ_bidir _, _) as typ)), _), id, _, _), _)) -> graph := G.add_edges (Mapping id) [] !graph; @@ -319,6 +327,7 @@ let add_def_to_graph graph def = | DEF_fundef fdef -> let id = id_of_fundef fdef in graph := G.add_edges (Function id) [] !graph; + scan_fundef_tannot (Function id) fdef; ignore (rewrite_fun (rewriters (Function id)) fdef) | DEF_mapdef mdef -> let id = id_of_mapdef mdef in