2 * Copyright (c) 2018, 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.
14 module Cls
= Typing_classes_heap
15 module SN
= Naming_special_names
17 let check_expr env
(pos
, e
) =
19 | Class_const
((_
, CIparent
), ((_
, construct
)))
20 when construct
= SN.Members.__construct
->
21 let tenv = Env.tast_env_as_typing_env env
in
22 begin match Env.get_class env
(Typing_env.get_parent_id
tenv) with
23 | Some parent_class
when Cls.kind parent_class
= Ast.Cabstract
->
24 if fst
(Cls.construct parent_class
) = None
then
25 Errors.parent_abstract_call construct
(fst pos
) (Cls.pos parent_class
);
30 let check_method_body env m
=
31 let named_body = m
.m_body
in
32 if m
.m_abstract
&& named_body.fb_ast
<> []
33 then Errors.abstract_with_body m
.m_name
;
34 let tenv = Env.tast_env_as_typing_env env
in
35 if not
(Typing_env.is_decl
tenv) && not m
.m_abstract
&& named_body.fb_ast
= []
36 then Errors.not_abstract_without_body m
.m_name
39 if c
.c_kind
= Ast.Cabstract
&& c
.c_final
then begin
41 Errors.nonstatic_method_in_abstract_final_class
(fst m
.m_name
) in
42 List.iter c
.c_methods
err;
43 Option.iter c
.c_constructor
err
47 inherit Tast_visitor.handler_base
49 method! at_expr env e
= check_expr env e
51 method! at_method_ env m
= check_method_body env m
53 method! at_class_ env c
= check_class env c