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.
11 module Reason
= Typing_reason
12 module Env
= Typing_env
13 module MakeType
= Typing_make_type
15 (*****************************************************************************)
17 (*****************************************************************************)
19 (* Tries to add constraint that ty_sub is subtype of ty_super in envs *)
20 let sub_type p ur env ty_sub ty_super on_error
=
22 log_with_level env
"sub" 1 (fun () ->
28 ( "Typing_ops.sub_type",
29 [Log_type
("ty_sub", ty_sub
); Log_type
("ty_super", ty_super
)]
34 (Reason.string_of_ureason ur
)
35 (fun () -> Typing_subtype.sub_type env ty_sub ty_super on_error
)
38 let sub_type_decl p ur env ty_sub ty_super
=
39 let (env
, ty_super
) = Typing_utils.localize_with_self env ty_super
in
40 let (env
, ty_sub
) = Typing_utils.localize_with_self env ty_sub
in
41 ignore
(sub_type p ur env ty_sub ty_super
Errors.unify_error
)
43 (* Ensure that types are equivalent i.e. subtypes of each other *)
44 let unify_decl p ur env ty1 ty2
=
45 let (env
, ty1
) = Typing_utils.localize_with_self env ty1
in
46 let (env
, ty2
) = Typing_utils.localize_with_self env ty2
in
47 ignore
(sub_type p ur env ty2 ty1
Errors.unify_error
);
48 ignore
(sub_type p ur env ty1 ty2
Errors.unify_error
)