Remove Aast.TCPartiallyAbstract
[hiphop-php.git] / hphp / hack / src / typing / nast_check / class_tparams_check.ml
blob0bb6d739cfafb529adea00eeb628f0bff9d4f0b4
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
13 type ctx = { class_tparams: Nast.tparam list }
15 let visitor =
16 object (this)
17 inherit [ctx] Nast_visitor.iter_with_state as super
19 method! on_hint (env, state) (pos, h) =
20 begin
21 match h with
22 | Habstr (tp_name, args) ->
23 List.iter
24 state.class_tparams
25 ~f:(fun { tp_name = (c_tp_pos, c_tp_name); _ } ->
26 if String.equal c_tp_name tp_name then
27 Errors.typeconst_depends_on_external_tparam
28 pos
29 c_tp_pos
30 c_tp_name);
31 List.iter args ~f:(this#on_hint (env, state))
32 | _ -> ()
33 end;
34 super#on_hint (env, state) (pos, h)
35 end
37 let handler =
38 object
39 inherit Nast_visitor.handler_base
41 method! at_class_ env c =
42 let state = { class_tparams = c.c_tparams } in
43 let on_hint = visitor#on_hint (env, state) in
44 List.iter c.c_typeconsts ~f:(fun t ->
45 match t.c_tconst_kind with
46 | TCAbstract
48 c_atc_as_constraint = a;
49 c_atc_super_constraint = s;
50 c_atc_default = d;
51 } ->
52 Option.iter a ~f:on_hint;
53 Option.iter s ~f:on_hint;
54 Option.iter d ~f:on_hint
55 | TCConcrete { c_tc_type = t } -> on_hint t)
56 end