@@ -845,20 +845,24 @@ let process_crate (cx:Semant.ctxt) (crate:Ast.crate) : unit =
845
845
Stack. push fn_ctx fn_ctx_stack
846
846
in
847
847
848
+ let push_fn_ctx_of_ty_fn (ty_fn :Ast.ty_fn ) : unit =
849
+ let (ty_sig, ty_fn_aux) = ty_fn in
850
+ let ret_ty = ty_sig.Ast. sig_output_slot.Ast. slot_ty in
851
+ let is_iter = ty_fn_aux.Ast. fn_is_iter in
852
+ push_fn_ctx (Common. option_get ret_ty) is_iter
853
+ in
854
+
848
855
let visit_mod_item_pre _ _ item =
849
- match item.Common. node.Ast. decl_item with
856
+ let { Common. node = item; Common. id = item_id } = item in
857
+ match item.Ast. decl_item with
850
858
Ast. MOD_ITEM_fn _ ->
851
- let id = item. Common. id in
859
+ let fn_ty = Hashtbl. find cx. Semant. ctxt_all_item_types item_id in
852
860
begin
853
- match Hashtbl. find cx.Semant. ctxt_all_item_types id with
854
- Ast. TY_fn (ty_sig , ty_fn_aux ) ->
855
- let ret_ty = ty_sig.Ast. sig_output_slot.Ast. slot_ty in
856
- let is_iter = ty_fn_aux.Ast. fn_is_iter in
857
- push_fn_ctx (Common. option_get ret_ty) is_iter
861
+ match fn_ty with
862
+ Ast. TY_fn ty_fn -> push_fn_ctx_of_ty_fn ty_fn
858
863
| _ ->
859
- Common. bug
860
- ()
861
- " Type.visit_mod_item_pre: fn item doesn't have a fn type"
864
+ Common. bug ()
865
+ " Type.visit_mod_item_pre: fn item didn't have a fn type"
862
866
end
863
867
| _ -> ()
864
868
in
@@ -869,10 +873,16 @@ let process_crate (cx:Semant.ctxt) (crate:Ast.crate) : unit =
869
873
| _ -> ()
870
874
in
871
875
872
- let visit_obj_fn_pre _ _ fn =
873
- let fn = fn.Common. node in
874
- let ret_ty = fn.Ast. fn_output_slot.Common. node.Ast. slot_ty in
875
- push_fn_ctx (Common. option_get ret_ty) fn.Ast. fn_aux.Ast. fn_is_iter
876
+ let visit_obj_fn_pre obj ident _ =
877
+ let obj_ty = Hashtbl. find cx.Semant. ctxt_all_item_types obj.Common. id in
878
+ match obj_ty with
879
+ Ast. TY_fn ({ Ast. sig_output_slot =
880
+ { Ast. slot_ty = Some (Ast. TY_obj (_ , methods )) } } , _ ) ->
881
+ push_fn_ctx_of_ty_fn (Hashtbl. find methods ident)
882
+ | _ ->
883
+ Common. bug ()
884
+ " Type.visit_obj_fn_pre: item doesn't have an object type (%a)"
885
+ Ast. sprintf_ty obj_ty
876
886
in
877
887
let visit_obj_fn_post _ _ _ = ignore (Stack. pop fn_ctx_stack) in
878
888
0 commit comments