solved some TODOs about Tgeneric type arguments (2)
[hiphop-php.git] / hphp / hack / src / typing / nast_check / const_prohibited_check.ml
blobc9bf64a5fd367ab8a0934f4672bedbe55cb02097
1 (*
2 * Copyright (c) 2018, Facebook, Inc.
3 * All rights reserved.
5 * This source code is licensed under the MIT license found in the
6 * LICENSE file in the "hack" directory of this source tree.
8 *)
10 open Hh_prelude
11 open Aast
12 open Nast_check_env
13 module SN = Naming_special_names
15 let has_const attrs = Naming_attributes.mem SN.UserAttributes.uaConst attrs
17 let error_if_const pos attrs =
18 if has_const attrs then
19 Errors.experimental_feature pos "The __Const attribute is not supported."
21 let handler =
22 object
23 inherit Nast_visitor.handler_base
25 method! at_class_ env c =
26 (* Const handling:
27 * disallow __Const attribute unless typechecker option is enabled
29 let pos = fst c.c_name in
30 if not (TypecheckerOptions.const_attribute (get_tcopt env)) then (
31 error_if_const pos c.c_user_attributes;
32 List.iter c.c_vars (fun cv -> error_if_const pos cv.cv_user_attributes)
34 end