2 * Copyright (c) 2015, Facebook, Inc.
5 * This source code is licensed under the MIT license found in the
6 * LICENSE file in the "hack" directory of this source tree.
13 module Env
= Typing_env
14 module Cls
= Folded_class
16 (* Not adding a Typing_dep here because it will be added when the
17 * Nast is fully processed (by the caller of this code) *)
18 let get_fun ctx name
=
19 match Decl_provider.get_fun ctx name
|> Decl_entry.to_option
with
20 | Some
{ fe_type
; _
} -> begin
21 match get_node fe_type
with
28 (ctx
: Provider_context.t
) (cls_name
: string) (meth_name
: string) =
29 match Decl_provider.get_class ctx cls_name
with
30 | Decl_entry.DoesNotExist
31 | Decl_entry.NotYetAvailable
->
33 | Decl_entry.Found cls
-> begin
34 match Cls.get_smethod cls meth_name
with
36 | Some
{ Typing_defs.ce_type
= (lazy ty
); _
} -> begin
37 match get_node ty
with
38 | Tfun fty
-> Some fty
43 let funopt_is_noreturn = function
44 | Some
{ ft_ret
; _
} -> is_prim Tnoreturn ft_ret
47 let static_meth_is_noreturn env ci meth_id
=
50 | CI cls_id
-> Some
(snd cls_id
)
54 | CIparent
-> Env.get_parent_id env
56 (* we declared the types, but didn't check the bodies yet
57 so can't tell anything here *)
62 (get_static_meth (Env.get_ctx env
) class_name (snd meth_id
))
65 let typed_expression_exits (ty
, _
, _e
) = is_type_no_return
(get_node ty
)
67 let expression_exits env
(_
, _
, e
) =
69 | Call
{ func
= (_
, _
, Id
(_
, fun_name
)); _
} ->
70 funopt_is_noreturn @@ get_fun (Env.get_ctx env
) fun_name
71 | Call
{ func
= (_
, _
, Class_const
((_
, _
, ci
), meth_id
)); _
} ->
72 static_meth_is_noreturn env ci meth_id
77 Env.expand_type env
(Env.get_return env
).Typing_env_return_info.return_type
79 is_prim Tnoreturn ret_ty