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 SN
= Naming_special_names
15 module UA
= SN.UserAttributes
16 module Cls
= Decl_provider.Class
21 inherit type_validator
as super
23 method! on_tapply acc r
(p
, h
) tyl
=
24 if String.equal h
SN.Classes.cTypename
then
25 this#invalid acc r
"a typename"
26 else if String.equal h
SN.Classes.cClassname
then
27 this#invalid acc r
"a classname"
29 String.equal h
SN.Typehints.wildcard
30 && not
(Env.get_allow_wildcards acc
.env
)
32 this#invalid acc r
"a wildcard"
34 super#on_tapply acc r
(p
, h
) tyl
36 method! on_tgeneric acc r t _tyargs
=
37 (* Ignoring type aguments: If there were any, then this generic variable isn't allowed to be
39 (* TODO(T70069116) actually implement that check *)
40 match Env.get_reified acc
.env t
with
41 | Nast.Erased
-> this#invalid acc r
"not reified"
42 | Nast.SoftReified
-> this#invalid acc r
"soft reified"
45 method! on_tvarray acc r _
= this#invalid acc r
"an array type"
47 method! on_tdarray acc r _ _
= this#invalid acc r
"an array type"
49 method! on_tvarray_or_darray acc r _ _
= this#invalid acc r
"an array type"
51 method! on_tfun acc r _
= this#invalid acc r
"a function type"
53 method! on_typeconst acc is_concrete typeconst
=
54 match typeconst
.ttc_abstract
with
55 | _
when Option.is_some typeconst
.ttc_reifiable
|| is_concrete
->
56 super#on_typeconst acc is_concrete typeconst
58 let r = Reason.Rwitness
(fst typeconst
.ttc_name
) in
60 "an abstract type constant without the __Reifiable attribute"
62 this#invalid acc
r kind
64 method! on_taccess acc
r (root
, ids
) =
66 match acc.reification
with
67 | Unresolved
-> this#on_type
acc root
70 super#on_taccess
acc r (root
, ids
)
72 method! on_tthis
acc r =
73 this#invalid
acc r "the late static bound this type"