From 9b4cf91b4f24fa35489c52bfd46eeed0a35e3d91 Mon Sep 17 00:00:00 2001 From: Catherine Gasnier Date: Wed, 28 Aug 2019 06:34:52 -0700 Subject: [PATCH] separate typing_env_types and typing_env Summary: This diff will allow constructors in Typing_make_type to actually call things like `union` and `intersect`. It separates Typing_env and Typing_env_types in two different modules to make it easier to deal with circular dependencies. (Typing_env used to *include* Typing_env_types, now it opens it). Now Typing_make_type can depend on Typing_env_types only, avoiding a circular dependency with Typing_env (see D16964381). Most modules referring to type `env` or other types and record fields now simply open Typing_env_types, the same way they open Typing_defs. Reviewed By: Wilfred Differential Revision: D16964286 fbshipit-source-id: 14e0ef9352f8ab7a3ddfbbb80a1fcadace9f9a17 --- hphp/hack/src/server/serverRewriteReturnType.ml | 2 +- hphp/hack/src/typing/dune | 3 - hphp/hack/src/typing/nastCheck.ml | 13 +- hphp/hack/src/typing/nastInitCheck.ml | 4 +- hphp/hack/src/typing/tast_env.ml | 26 ++-- hphp/hack/src/typing/tast_env.mli | 4 +- hphp/hack/src/typing/tast_typecheck.ml | 3 +- hphp/hack/src/typing/type_mapper.ml | 5 +- hphp/hack/src/typing/type_parameter_env_ops.mli | 9 +- hphp/hack/src/typing/typing.ml | 158 ++++++++++----------- hphp/hack/src/typing/typing_arrays.ml | 1 + hphp/hack/src/typing/typing_debug.ml | 10 +- hphp/hack/src/typing/typing_enforceability.ml | 5 +- hphp/hack/src/typing/typing_env.ml | 11 +- hphp/hack/src/typing/typing_env.mli | 5 +- hphp/hack/src/typing/typing_env_types.ml | 12 ++ ...ping_env_types_sig.mli => typing_env_types.mli} | 4 +- hphp/hack/src/typing/typing_expand.mli | 2 +- hphp/hack/src/typing/typing_extends.mli | 2 +- hphp/hack/src/typing/typing_exts.ml | 17 +-- hphp/hack/src/typing/typing_generic_constraint.ml | 7 +- hphp/hack/src/typing/typing_intersection.mli | 12 +- hphp/hack/src/typing/typing_lenv.ml | 4 +- hphp/hack/src/typing/typing_lenv.mli | 83 +++++------ hphp/hack/src/typing/typing_log.ml | 3 +- hphp/hack/src/typing/typing_memoize.ml | 11 +- hphp/hack/src/typing/typing_memoize.mli | 4 +- hphp/hack/src/typing/typing_mutability.ml | 22 +-- hphp/hack/src/typing/typing_mutability.mli | 12 +- hphp/hack/src/typing/typing_per_cont_ops.mli | 37 ++--- hphp/hack/src/typing/typing_phase.ml | 21 ++- hphp/hack/src/typing/typing_phase.mli | 57 ++++---- hphp/hack/src/typing/typing_print.ml | 9 +- hphp/hack/src/typing/typing_print.mli | 19 +-- hphp/hack/src/typing/typing_reactivity.ml | 13 +- hphp/hack/src/typing/typing_requirements.mli | 2 +- hphp/hack/src/typing/typing_return.mli | 28 ++-- hphp/hack/src/typing/typing_solver.ml | 19 +-- hphp/hack/src/typing/typing_solver.mli | 29 ++-- hphp/hack/src/typing/typing_substring.ml | 5 +- hphp/hack/src/typing/typing_subtype.ml | 73 +++++----- hphp/hack/src/typing/typing_subtype.mli | 33 ++--- hphp/hack/src/typing/typing_subtype_tconst.mli | 9 +- hphp/hack/src/typing/typing_taccess.ml | 6 +- hphp/hack/src/typing/typing_taccess.mli | 3 +- hphp/hack/src/typing/typing_union.mli | 11 +- hphp/hack/src/typing/typing_utils.ml | 45 +++--- hphp/hack/src/typing/typing_visibility.mli | 7 +- hphp/hack/src/typing/typing_xhp.mli | 8 +- 49 files changed, 454 insertions(+), 434 deletions(-) rename hphp/hack/src/typing/{typing_env_types_sig.mli => typing_env_types.mli} (96%) diff --git a/hphp/hack/src/server/serverRewriteReturnType.ml b/hphp/hack/src/server/serverRewriteReturnType.ml index 13ebd80cb95..c232a58e000 100644 --- a/hphp/hack/src/server/serverRewriteReturnType.ml +++ b/hphp/hack/src/server/serverRewriteReturnType.ml @@ -43,7 +43,7 @@ let print_ty ty = It indexes those types with the span of the associated function (or method) declaration *) module Collector = struct - type t = (Aast.pos * (Typing_env.env * Tast.ty)) array + type t = (Aast.pos * (Typing_env_types.env * Tast.ty)) array (* retrieve a type from a type_hint *) let type_of_type_hint env (ty, _) = (Pos.none, Tast_expand.expand_ty env ty) diff --git a/hphp/hack/src/typing/dune b/hphp/hack/src/typing/dune index adff9108ab1..25742359a3e 100644 --- a/hphp/hack/src/typing/dune +++ b/hphp/hack/src/typing/dune @@ -56,7 +56,6 @@ typing_env_from_def typing_env_return_info typing_env_types - typing_env_types_sig typing_equality_check typing_expand typing_fake_members @@ -88,8 +87,6 @@ typing_variance typing_visibility typing_xhp) - (modules_without_implementation - typing_env_types_sig) (libraries common decl diff --git a/hphp/hack/src/typing/nastCheck.ml b/hphp/hack/src/typing/nastCheck.ml index 73c01974a7a..55e0a9101db 100644 --- a/hphp/hack/src/typing/nastCheck.ml +++ b/hphp/hack/src/typing/nastCheck.ml @@ -24,6 +24,7 @@ open Core_kernel open Aast open Typing_defs +open Typing_env_types open Utils module Env = Typing_env @@ -37,7 +38,7 @@ module Cls = Decl_provider.Class type env = { typedef_tparams : Nast.tparam list; - tenv: Env.env; + tenv: Typing_env_types.env; } let rec fun_ tenv f = let env = { typedef_tparams = []; @@ -48,7 +49,7 @@ let rec fun_ tenv f = and where constraints *) let ety_env = Phase.env_with_self env.tenv in let f_tparams : decl tparam list = List.map f.f_tparams - ~f:(Decl_hint.aast_tparam_to_decl_tparam env.tenv.Env.decl_env) in + ~f:(Decl_hint.aast_tparam_to_decl_tparam env.tenv.decl_env) in let tenv, constraints = Phase.localize_generic_parameters_with_bounds env.tenv f_tparams ~ety_env in @@ -118,11 +119,11 @@ and hint_ env p = function | Hpu_access (h, _) -> hint env h and check_happly unchecked_tparams env h = - let decl_ty = Decl_hint.hint env.Env.decl_env h in + let decl_ty = Decl_hint.hint env.decl_env h in let unchecked_tparams = List.map unchecked_tparams begin fun t -> let cstrl = List.map t.tp_constraints (fun (ck, cstr) -> - let cstr = Decl_hint.hint env.Env.decl_env cstr in + let cstr = Decl_hint.hint env.decl_env cstr in (ck, cstr)) in { Typing_defs.tp_variance = t.tp_variance; @@ -181,7 +182,7 @@ and class_ tenv c = } in (* Add type parameters to typing environment and localize the bounds *) let c_tparam_list : decl tparam list = List.map c.c_tparams.c_tparam_list - ~f:(Decl_hint.aast_tparam_to_decl_tparam env.tenv.Env.decl_env) in + ~f:(Decl_hint.aast_tparam_to_decl_tparam env.tenv.decl_env) in let tenv, constraints = Phase.localize_generic_parameters_with_bounds tenv c_tparam_list ~ety_env:(Phase.env_with_self tenv) in let tenv = add_constraints (fst c.c_name) tenv constraints in @@ -223,7 +224,7 @@ and method_ env m = and where constraints *) let ety_env = Phase.env_with_self env.tenv in let m_tparams : decl tparam list = List.map m.m_tparams - ~f:(Decl_hint.aast_tparam_to_decl_tparam env.tenv.Env.decl_env) in + ~f:(Decl_hint.aast_tparam_to_decl_tparam env.tenv.decl_env) in let tenv, constraints = Phase.localize_generic_parameters_with_bounds env.tenv m_tparams ~ety_env in let tenv = add_constraints (fst m.m_name) tenv constraints in diff --git a/hphp/hack/src/typing/nastInitCheck.ml b/hphp/hack/src/typing/nastInitCheck.ml index de47653a7ff..e1abc771df9 100644 --- a/hphp/hack/src/typing/nastInitCheck.ml +++ b/hphp/hack/src/typing/nastInitCheck.ml @@ -100,7 +100,7 @@ module Env = struct type t = { methods : method_status ref SMap.t ; props : SSet.t ; - tenv : Typing_env.env ; + tenv : Typing_env_types.env ; class_init_props: SSet.t; } @@ -130,7 +130,7 @@ module Env = struct DeferredMembers.parent_props tenv, DeferredMembers.parent tenv else - let decl_env = tenv.Typing_env.decl_env in + let decl_env = tenv.Typing_env_types.decl_env in DICheck.initialized_props, DICheck.trait_props decl_env, DICheck.parent_props decl_env, diff --git a/hphp/hack/src/typing/tast_env.ml b/hphp/hack/src/typing/tast_env.ml index 37c23d44401..961b9e10da9 100644 --- a/hphp/hack/src/typing/tast_env.ml +++ b/hphp/hack/src/typing/tast_env.ml @@ -24,7 +24,7 @@ open Aast let show_env _ = "" let pp_env _ _ = Printf.printf "%s\n" "" -type env = Typing_env.env +type env = Typing_env_types.env type t = env [@@deriving show] exception Not_in_class @@ -65,10 +65,10 @@ let get_tcopt = Typing_env.get_tcopt let expand_type = Typing_env.expand_type let set_static = Typing_env.set_static let set_val_kind = Typing_env.set_val_kind -let set_inside_constructor env = { env with Typing_env.inside_constructor = true } -let get_inside_constructor env = env.Typing_env.inside_constructor -let get_decl_env env = env.Typing_env.decl_env -let get_inside_ppl_class env = env.Typing_env.inside_ppl_class +let set_inside_constructor env = { env with Typing_env_types.inside_constructor = true } +let get_inside_constructor env = env.Typing_env_types.inside_constructor +let get_decl_env env = env.Typing_env_types.decl_env +let get_inside_ppl_class env = env.Typing_env_types.inside_ppl_class let get_val_kind = Typing_env.get_val_kind let get_file = Typing_env.get_file let fully_expand = Typing_expand.fully_expand @@ -80,7 +80,7 @@ let get_concrete_supertypes = Typing_utils.get_concrete_supertypes let is_visible = Typing_visibility.is_visible let assert_nontrivial = Typing_equality_check.assert_nontrivial let assert_nullable = Typing_equality_check.assert_nullable -let hint_to_ty env = Decl_hint.hint env.Typing_env.decl_env +let hint_to_ty env = Decl_hint.hint env.Typing_env_types.decl_env let localize env ety_env = Typing_phase.localize ~ety_env env let localize_with_self = Typing_phase.localize_with_self let localize_with_dty_validator = Typing_phase.localize_with_dty_validator @@ -112,7 +112,7 @@ let referenced_typeconsts env root ids = let empty tcopt = Typing_env.empty tcopt Relative_path.default ~droot:None let restore_saved_env env saved_env = - let module Env = Typing_env in + let module Env = Typing_env_types in {env with Env.genv = { env.Env.genv with @@ -170,11 +170,11 @@ let def_env d = | FileAttributes _ -> empty GlobalOptions.default let set_ppl_lambda env = - { env with Typing_env.inside_ppl_class = false } + { env with Typing_env_types.inside_ppl_class = false } let get_anonymous_lambda_types env id = match Typing_env.get_anonymous env id with - | Some { Typing_env. counter = ftys; _ } -> + | Some { Typing_env_types. counter = ftys; _ } -> let (untyped, typed) = !ftys in untyped @ typed | _ -> @@ -191,7 +191,7 @@ let get_enum = Typing_env.get_enum let is_enum = Typing_env.is_enum -let env_reactivity = Typing_env.env_reactivity +let env_reactivity = Typing_env_types.env_reactivity let function_is_mutable = Typing_env.function_is_mutable @@ -199,11 +199,11 @@ let local_is_mutable = Typing_env.local_is_mutable let get_env_mutability = Typing_env.get_env_mutability -let get_fun = Typing_env.get_fun +let get_fun = Typing_env_types.get_fun let set_env_reactive = Typing_env.set_env_reactive -let set_allow_wildcards env = { env with Typing_env.allow_wildcards = true } +let set_allow_wildcards env = { env with Typing_env_types.allow_wildcards = true } -let get_allow_wildcards env = env.Typing_env.allow_wildcards +let get_allow_wildcards env = env.Typing_env_types.allow_wildcards let condition_type_matches = Typing_reactivity.condition_type_matches diff --git a/hphp/hack/src/typing/tast_env.mli b/hphp/hack/src/typing/tast_env.mli index a3827c9402e..d3d627a4d36 100644 --- a/hphp/hack/src/typing/tast_env.mli +++ b/hphp/hack/src/typing/tast_env.mli @@ -241,8 +241,8 @@ val set_ppl_lambda : env -> env val get_anonymous_lambda_types : env -> int -> Tast.ty list -val typing_env_as_tast_env : Typing_env.env -> env -val tast_env_as_typing_env : env -> Typing_env.env +val typing_env_as_tast_env : Typing_env_types.env -> env +val tast_env_as_typing_env : env -> Typing_env_types.env val can_coerce : Pos.t -> env -> Tast.ty -> Tast.possibly_enforced_ty -> Errors.typing_error_callback -> env option diff --git a/hphp/hack/src/typing/tast_typecheck.ml b/hphp/hack/src/typing/tast_typecheck.ml index 1f659b9dd22..c56349cb87b 100644 --- a/hphp/hack/src/typing/tast_typecheck.ml +++ b/hphp/hack/src/typing/tast_typecheck.ml @@ -11,6 +11,7 @@ open Hh_core open Delta open Typing_defs +open Typing_env_types open Aast module ETast = Tast @@ -223,7 +224,7 @@ let localize env hint = match hint with | None -> failwith "There should be a hint in strict mode." | Some decl_ty -> - let ty = Decl_hint.hint env.Env.decl_env decl_ty in + let ty = Decl_hint.hint env.decl_env decl_ty in let _env, ty = Phase.localize ~ety_env:(Phase.env_with_self env) env ty in ty diff --git a/hphp/hack/src/typing/type_mapper.ml b/hphp/hack/src/typing/type_mapper.ml index 278a69aa0de..1ae0f0f6d0c 100644 --- a/hphp/hack/src/typing/type_mapper.ml +++ b/hphp/hack/src/typing/type_mapper.ml @@ -12,14 +12,11 @@ open Core_kernel [@@@warning "+33"] open Common open Typing_defs +open Typing_env_types module Env = Typing_env module Reason = Typing_reason -(* Mapping environment threaded through all function calls: - * - typing environment *) -type env = Env.env - (* Mapping result - updated environment, mapped type *) type result = env * locl ty diff --git a/hphp/hack/src/typing/type_parameter_env_ops.mli b/hphp/hack/src/typing/type_parameter_env_ops.mli index 48f8064124a..477293a1141 100644 --- a/hphp/hack/src/typing/type_parameter_env_ops.mli +++ b/hphp/hack/src/typing/type_parameter_env_ops.mli @@ -9,6 +9,7 @@ module Env = Typing_env open Typing_defs +open Typing_env_types (** Given a list of type parameter names, attempt to simplify away those type parameters by looking for a type to which they are equal in the tpenv. @@ -16,13 +17,13 @@ If such a type exists, remove the type parameter from the tpenv. Returns a set of substitutions mapping each type parameter name to the type to which it is equal if found, otherwise to itself. *) val simplify_tpenv : - Env.env -> + env -> (('a tparam * string) option * locl ty) list -> Typing_reason.t -> - Env.env * locl ty SMap.t + env * locl ty SMap.t val join : - Env.env -> + env -> Type_parameter_env.t -> Type_parameter_env.t -> - Env.env * Type_parameter_env.t + env * Type_parameter_env.t diff --git a/hphp/hack/src/typing/typing.ml b/hphp/hack/src/typing/typing.ml index 94cbbf07caf..27d23d92f94 100644 --- a/hphp/hack/src/typing/typing.ml +++ b/hphp/hack/src/typing/typing.ml @@ -17,6 +17,7 @@ open Common open Aast open Tast open Typing_defs +open Typing_env_types open Utils module TFTerm = Typing_func_terminality @@ -251,12 +252,12 @@ let get_darray_inst ty = | (_, Tarraykind (AKdarray (kty, vty))) -> Some (kty, vty) | _ -> get_key_value_collection_inst ty -let with_timeout env fun_name ~(do_ : Env.env -> 'b): 'b option = +let with_timeout env fun_name ~(do_ : env -> 'b): 'b option = let timeout = (Env.get_tcopt env).GlobalOptions.tco_timeout in if timeout = 0 then Some (do_ env) else let big_envs = ref [] in - let env = { env with Env.big_envs } in + let env = { env with big_envs } in Timeout.with_timeout ~timeout ~on_timeout:(fun _ -> List.iter !big_envs (fun (p, env) -> @@ -385,11 +386,11 @@ let make_param_local_ty env param = else env, (r, TUtils.tany env) | Some x -> - let ty = Decl_hint.hint env.Env.decl_env x in + let ty = Decl_hint.hint env.decl_env x in let { et_type = ty; _ } = Typing_enforceability.compute_enforced_and_pessimize_ty_simple env ty in let condition_type = - Decl_fun_utils.condition_type_from_attributes env.Env.decl_env param.param_user_attributes in + Decl_fun_utils.condition_type_from_attributes env.decl_env param.param_user_attributes in begin match condition_type with | Some condition_type -> let env, ty = Phase.localize ~ety_env env ty in @@ -433,7 +434,7 @@ let rec bind_param env (ty1, param) = | Some e -> let decl_hint = Option.map - ~f:(Decl_hint.hint env.Env.decl_env) + ~f:(Decl_hint.hint env.decl_env) (hint_of_type_hint param.param_type_hint) in let enforced = @@ -535,21 +536,21 @@ and fun_def tcopt f : Tast.fun_def option = let pos = fst f.f_name in let nb = TNBody.func_body f in add_decl_errors (Option.map - (Env.get_fun env (snd f.f_name)) + (get_fun env (snd f.f_name)) ~f:(fun x -> Option.value_exn x.ft_decl_errors) ); let env = Env.open_tyvars env (fst f.f_name) in let env = Env.set_env_function_pos env pos in let env = Env.set_env_pessimize env in let env = Typing_attributes.check_def env new_object SN.AttributeKinds.fn f.f_user_attributes in - let reactive = fun_reactivity env.Env.decl_env f.f_user_attributes f.f_params in + let reactive = fun_reactivity env.decl_env f.f_user_attributes f.f_params in let mut = TUtils.fun_mutable f.f_user_attributes in let env = Env.set_env_reactive env reactive in let env = Env.set_fun_mutable env mut in NastCheck.fun_ env f; let ety_env = Phase.env_with_self env in let f_tparams : decl tparam list = List.map f.f_tparams - ~f:(Decl_hint.aast_tparam_to_decl_tparam env.Env.decl_env) in + ~f:(Decl_hint.aast_tparam_to_decl_tparam env.decl_env) in let env, constraints = Phase.localize_generic_parameters_with_bounds env f_tparams ~ety_env in @@ -558,7 +559,7 @@ and fun_def tcopt f : Tast.fun_def option = Phase.localize_where_constraints ~ety_env env f.f_where_constraints in let decl_ty = Option.map - ~f:(Decl_hint.hint env.Env.decl_env) + ~f:(Decl_hint.hint env.decl_env) (hint_of_type_hint f.f_ret) in let env = Env.set_fn_kind env f.f_fun_kind in let (env, locl_ty) = @@ -749,12 +750,12 @@ and enforce_return_disposable _env e = * This enables significant perf improvement, because this is called at every * function of method call, when most calls are outside of a try block. *) and move_and_merge_next_in_catch env = - if env.Env.in_try || (TFTerm.is_noreturn env) + if env.in_try || (TFTerm.is_noreturn env) then LEnv.move_and_merge_next_in_cont env C.Catch else LEnv.drop_cont env C.Next and save_and_merge_next_in_catch env = - if env.Env.in_try || (TFTerm.is_noreturn env) + if env.in_try || (TFTerm.is_noreturn env) then LEnv.save_and_merge_next_in_cont env C.Catch else env @@ -770,7 +771,7 @@ and stmt_ env pos st = (fun (env, tb) -> Typing_solver.close_tyvars_and_solve env Errors.unify_error, tb) @@ match st with | Fallthrough -> - let env = if env.Env.in_case + let env = if env.in_case then LEnv.move_and_merge_next_in_cont env C.Fallthrough else env in env, T.Fallthrough @@ -793,16 +794,16 @@ and stmt_ env pos st = * locally for checking b1. For example, we might have condition * $x === null, or $x is C, which changes the type of $x in * lenv *) - let parent_lenv = env.Env.lenv in + let parent_lenv = env.lenv in let env = condition env true te in let env, tb1 = block env b1 in - let lenv1 = env.Env.lenv in + let lenv1 = env.lenv in - let env = { env with Env.lenv = parent_lenv } in + let env = { env with lenv = parent_lenv } in let env = condition env false te in let env, tb2 = block env b2 in - let lenv2 = env.Env.lenv in + let lenv2 = env.lenv in let env = LEnv.union_lenvs env parent_lenv lenv1 lenv2 in (* TODO TAST: annotate with joined types *) @@ -832,13 +833,13 @@ and stmt_ env pos st = if return_disposable then enforce_return_disposable env e; let env, te, rty = expr ~is_using_clause:return_disposable ?expected:expected env e in let env = - if Env.env_reactivity env <> Nonreactive + if env_reactivity env <> Nonreactive then begin Typing_mutability.handle_value_in_return ~function_returns_mutable:return_mutable ~function_returns_void_for_rx: return_void_to_rx env - env.Env.function_pos + env.function_pos te end else env in @@ -863,7 +864,7 @@ and stmt_ env pos st = * case there is no iteration *) let env = LEnv.save_and_merge_next_in_cont env C.Continue in let alias_depth = - if env.Env.in_loop then 1 else Typing_alias.get_depth (pos, st) in + if env.in_loop then 1 else Typing_alias.get_depth (pos, st) in let env, tb = Env.in_loop env begin iter_n_acc alias_depth begin fun env -> let env = LEnv.update_next_from_conts env [C.Continue; C.Next] in @@ -885,7 +886,7 @@ and stmt_ env pos st = let env, (te, tb) = LEnv.stash_and_do env [C.Continue; C.Break] (fun env -> let env = LEnv.save_and_merge_next_in_cont env C.Continue in let alias_depth = - if env.Env.in_loop then 1 else Typing_alias.get_depth (pos, st) in + if env.in_loop then 1 else Typing_alias.get_depth (pos, st) in let env, tb = Env.in_loop env begin iter_n_acc alias_depth begin fun env -> let env = LEnv.update_next_from_conts env [C.Continue; C.Next] in @@ -930,7 +931,7 @@ and stmt_ env pos st = let (env, te1, _) = expr env e1 in (* initializer *) let env = LEnv.save_and_merge_next_in_cont env C.Continue in let alias_depth = - if env.Env.in_loop then 1 else Typing_alias.get_depth (pos, st) in + if env.in_loop then 1 else Typing_alias.get_depth (pos, st) in let env, (tb, te3) = Env.in_loop env begin iter_n_acc alias_depth begin fun env -> (* The following is necessary in case there is an assignment in the @@ -974,7 +975,7 @@ and stmt_ env pos st = let env = LEnv.save_and_merge_next_in_cont env C.Continue in let env, tk, tv = as_expr env ty1 (fst e1) e2 in let alias_depth = - if env.Env.in_loop then 1 else Typing_alias.get_depth (pos, st) in + if env.in_loop then 1 else Typing_alias.get_depth (pos, st) in let env, (te2, tb) = Env.in_loop env begin iter_n_acc alias_depth begin fun env -> let env = LEnv.update_next_from_conts env [C.Continue; C.Next] in @@ -1032,7 +1033,7 @@ and stmt_ env pos st = | Some (p, h) -> let ety_env = { (Phase.env_with_self env) with from_class = Some CIstatic; } in - let hint_ty = Decl_hint.hint env.Env.decl_env (p, h) in + let hint_ty = Decl_hint.hint env.decl_env (p, h) in let env, hint_ty = Phase.localize ~ety_env env hint_ty in env, Some hint_ty, Some (ExpectedTy.make p Reason.URhint hint_ty) | None -> env, None, None @@ -1101,7 +1102,7 @@ and try_catch env tb cl fb = let catchctx = LEnv.get_cont_option env C.Catch in let env, lenvtcblist = List.map_env env ~f:(catch catchctx) cl in let lenvl, tcb = List.unzip lenvtcblist in - let env = LEnv.union_lenv_list env env.Env.lenv lenvl in + let env = LEnv.union_lenv_list env env.lenv lenvl in let env = LEnv.move_and_merge_next_in_cont env C.Finally in env, (ttb, tcb)) in let env, tfb = finally env fb in @@ -1177,7 +1178,7 @@ and catch catchctx env (sid, exn, b) = let env = exception_ty ety_p env ety in let env = set_local env exn ety in let env, tb = block env b in - env, (env.Env.lenv, (sid, exn, tb)) + env, (env.lenv, (sid, exn, tb)) and as_expr env ty1 pe e = let env = Env.open_tyvars env pe in @@ -1327,7 +1328,7 @@ and loop_forever env = and eif env ~(expected: ExpectedTy.t option) p c e1 e2 = let condition = condition ~lhs_of_null_coalesce:false in let env, tc, tyc = raw_expr ~lhs_of_null_coalesce:false env c in - let parent_lenv = env.Env.lenv in + let parent_lenv = env.lenv in let env = condition env true tc in let env, te1, ty1 = match e1 with @@ -1338,12 +1339,12 @@ and eif env ~(expected: ExpectedTy.t option) p c e1 e2 = let env, te1, ty1 = expr ?expected env e1 in env, Some te1, ty1 in - let lenv1 = env.Env.lenv in + let lenv1 = env.lenv in - let env = { env with Env.lenv = parent_lenv } in + let env = { env with lenv = parent_lenv } in let env = condition env false tc in let env, te2, ty2 = expr ?expected env e2 in - let lenv2 = env.Env.lenv in + let lenv2 = env.lenv in let env = LEnv.union_lenvs env parent_lenv lenv1 lenv2 in let env, ty = Union.union env ty1 ty2 in @@ -2114,10 +2115,10 @@ and expr_ | Binop ((Ast_defs.Ampamp | Ast_defs.Barbar as bop), e1, e2) -> let c = bop = Ast_defs.Ampamp in let env, te1, _ = expr env e1 in - let lenv = env.Env.lenv in + let lenv = env.lenv in let env = condition env c te1 in let env, te2, _ = expr env e2 in - let env = { env with Env.lenv = lenv } in + let env = { env with lenv = lenv } in make_result env p (T.Binop(bop, te1, te2)) (MakeType.bool (Reason.Rlogic_ret p)) | Binop (bop, e1, e2) -> let env, te1, ty1 = raw_expr env e1 in @@ -2395,7 +2396,7 @@ and expr_ let is_anon = match e with Efun _ -> true | Lfun _ -> false | _ -> assert false in (* This is the function type as declared on the lambda itself. * If type hints are absent then use Tany instead. *) - let declared_ft = Decl.fun_decl_in_env env.Env.decl_env f in + let declared_ft = Decl.fun_decl_in_env env.decl_env f in let declared_ft = Typing_enforceability.compute_enforced_and_pessimize_fun_type_simple env declared_ft in (* When creating a closure, the 'this' type will mean the late bound type * of the current enclosing class @@ -2415,20 +2416,19 @@ and expr_ (* Is the return type declared? *) let is_explicit_ret = Option.is_some (hint_of_type_hint f.f_ret) in let reactivity = - Decl_fun_utils.fun_reactivity_opt env.Env.decl_env f.f_user_attributes - |> Option.value ~default:(TR.strip_conditional_reactivity (Env.env_reactivity env)) in + Decl_fun_utils.fun_reactivity_opt env.decl_env f.f_user_attributes + |> Option.value ~default:(TR.strip_conditional_reactivity (env_reactivity env)) in let check_body_under_known_params env ?ret_ty ft = - let old_reactivity = Env.env_reactivity env in + let old_reactivity = env_reactivity env in let env = Env.set_env_reactive env reactivity in - let old_inside_ppl_class = env.Typing_env.inside_ppl_class in - let env = { env with Typing_env.inside_ppl_class = false } in + let old_inside_ppl_class = env.inside_ppl_class in + let env = { env with inside_ppl_class = false } in let ft = { ft with ft_reactive = reactivity } in let (is_coroutine, _counter, _, anon) = anon_make env p f ft idl is_anon outer in let ft = { ft with ft_is_coroutine = is_coroutine } in let env, tefun, ty = anon ?ret_ty env ft.ft_params ft.ft_arity in let env = Env.set_env_reactive env old_reactivity in - let env = { env with - Typing_env.inside_ppl_class = old_inside_ppl_class; } in + let env = { env with inside_ppl_class = old_inside_ppl_class; } in let inferred_ty = (Reason.Rwitness p, Tfun { ft with ft_ret = if is_explicit_ret then declared_ft.ft_ret else MakeType.unenforced ty }) in @@ -2567,15 +2567,15 @@ and expr_ else begin Typing_log.increment_feature_count env FL.Lambda.unknown_params; (* check for recursive function calls *) - let reactivity = fun_reactivity env.Env.decl_env f.f_user_attributes f.f_params in - let old_reactivity = Env.env_reactivity env in + let reactivity = fun_reactivity env.decl_env f.f_user_attributes f.f_params in + let old_reactivity = env_reactivity env in let env = Env.set_env_reactive env reactivity in let is_coroutine, counter, pos, anon = anon_make env p f declared_ft idl is_anon outer in let env, tefun, _, anon_id = Errors.try_with_error (fun () -> let (_, tefun, ty) = anon env declared_ft.ft_params declared_ft.ft_arity in let anon_fun = - { Env. rx = reactivity ; typecheck = anon + { rx = reactivity ; typecheck = anon ; is_coroutine ; counter ; pos } in let env, anon_id = Env.add_anonymous env anon_fun in env, tefun, ty, anon_id) @@ -2586,7 +2586,7 @@ and expr_ Errors.ignore_ (fun () -> (anon env fun_params)) in let (_, tefun, ty) = anon_ign env declared_ft.ft_params declared_ft.ft_arity in let anon_fun = - { Env. rx = reactivity ; typecheck = anon + { rx = reactivity ; typecheck = anon ; is_coroutine ; counter ; pos } in let env, anon_id = Env.add_anonymous env anon_fun in env, tefun, ty, anon_id) in @@ -2733,7 +2733,7 @@ and xhp_attribute_exprs env cid attrl = (*****************************************************************************) (* Anonymous functions. *) (*****************************************************************************) -and anon_bind_param params (env, t_params) ty : Env.env * Tast.fun_param list = +and anon_bind_param params (env, t_params) ty : env * Tast.fun_param list = match !params with | [] -> (* This code cannot be executed normally, because the arity is wrong @@ -2745,7 +2745,7 @@ and anon_bind_param params (env, t_params) ty : Env.env * Tast.fun_param list = match hint_of_type_hint param.param_type_hint with | Some h -> - let h = Decl_hint.hint env.Env.decl_env h in + let h = Decl_hint.hint env.decl_env h in (* When creating a closure, the 'this' type will mean the * late bound type of the current enclosing class *) @@ -2778,7 +2778,7 @@ and anon_bind_variadic env vparam variadic_ty = (* if the hint is missing, use the type we expect *) env, variadic_ty, Reason.to_pos (fst variadic_ty) | Some hint -> - let h = Decl_hint.hint env.Env.decl_env hint in + let h = Decl_hint.hint env.decl_env hint in let ety_env = { (Phase.env_with_self env) with from_class = Some CIstatic; } in let env, h = Phase.localize ~ety_env env h in @@ -2793,7 +2793,7 @@ and anon_bind_variadic env vparam variadic_ty = env, t_variadic -and anon_bind_opt_param env param : Env.env = +and anon_bind_opt_param env param : env = match param.param_expr with | None -> let ty = Reason.Rwitness param.param_pos, Typing_utils.tany env in @@ -2840,7 +2840,7 @@ and stash_conts_for_anon env p is_anon captured f = (* Make a type-checking function for an anonymous function. *) and anon_make tenv p f ft idl is_anon outer = - let anon_lenv = tenv.Env.lenv in + let anon_lenv = tenv.lenv in let is_typing_self = ref false in let nb = Nast.assert_named_body f.f_body in let is_coroutine = f.f_fun_kind = Ast_defs.FCoroutine in @@ -2923,7 +2923,7 @@ and anon_make tenv p f ft idl is_anon outer = let env = Env.set_fn_kind env f.f_fun_kind in let decl_ty = Option.map - ~f:(Decl_hint.hint env.Env.decl_env) + ~f:(Decl_hint.hint env.decl_env) (hint_of_type_hint f.f_ret) in let env, hret = match decl_ty with @@ -3305,7 +3305,7 @@ and assign_ p ur env e1 ty2 = env, te::tel) in make_result env (fst e1) (T.List (List.rev reversed_tel)) ty2 | pobj, Obj_get (obj, (pm, Id (_, member_name as m)), nullflavor) -> - let lenv = env.Env.lenv in + let lenv = env.lenv in let no_fakes = LEnv.env_with_empty_fakes env in (* In this section, we check that the assignment is compatible with * the real type of a member. Remember that members can change @@ -3328,7 +3328,7 @@ and assign_ p ur env e1 ty2 = Tast.make_typed_expr pobj result (T.Obj_get (tobj, Tast.make_typed_expr pm result (T.Id m), nullflavor)) in - let env = { env with Env.lenv = lenv } in + let env = { env with lenv = lenv } in begin match obj with | _, This -> let env, local = Env.FakeMembers.make env obj member_name in @@ -3341,19 +3341,19 @@ and assign_ p ur env e1 ty2 = | _ -> env, te1, ty2 end | _, Obj_get _ -> - let lenv = env.Env.lenv in + let lenv = env.lenv in let no_fakes = LEnv.env_with_empty_fakes env in let env, te1, real_type = lvalue no_fakes e1 in let env, exp_real_type = Env.expand_type env real_type in - let env = { env with Env.lenv = lenv } in + let env = { env with lenv = lenv } in let env = Type.coerce_type p ur env ty2 (MakeType.unenforced exp_real_type) Errors.unify_error in env, te1, ty2 | _, Class_get (_, CGexpr _) -> failwith "AST should not have any CGexprs after naming" | _, Class_get ((pos_classid, x), CGstring (pos_member, y)) -> - let lenv = env.Env.lenv in + let lenv = env.lenv in let no_fakes = LEnv.env_with_empty_fakes env in let env, te1, _ = lvalue no_fakes e1 in - let env = { env with Env.lenv = lenv } in + let env = { env with lenv = lenv } in let env, ety2 = Env.expand_type env ty2 in (* This defers the coercion check to class_get, which looks up the appropriate target type *) let env, _, cty = static_class_id ~check_constraints:false pos_classid env [] x in @@ -3533,7 +3533,7 @@ and call_parent_construct pos env el uel = env, Some (Option.value_map (Env.get_anonymous env id) ~default:false - ~f:(fun ty_ -> ty_.Env.is_coroutine) + ~f:(fun ty_ -> ty_.is_coroutine) ) | Tunion ts | Tintersection ts -> are_coroutines env ts | _ -> @@ -3823,7 +3823,7 @@ and call_parent_construct pos env el uel = X -> f, where f R = Y *) let rec build_output_container - env (x:locl ty) : (Env.env * (locl ty -> locl ty)) = + env (x:locl ty) : (env * (locl ty -> locl ty)) = let env, x = Env.expand_type env x in match x with | (_, Tarraykind (AKany | AKempty)) as array_type -> @@ -3895,7 +3895,7 @@ and call_parent_construct pos env el uel = (* Directly call get_fun so that we can muck with the type before * instantiation -- much easier to work in terms of Tgeneric Tk/Tv than * trying to figure out which Tvar is which. *) - (match Env.get_fun env (snd id) with + (match get_fun env (snd id) with | Some fty -> let param1, param2, param3 = match fty.ft_params with @@ -4063,7 +4063,7 @@ and call_parent_construct pos env el uel = make_call env (Tast.make_typed_expr fpos fty (T.Class_const (tcid, m))) tal tel tuel method_ (* <<__PPL>>: sample, factor, observe, condition *) - | Id (pos, id) when env.Env.inside_ppl_class && SN.PPLFunctions.is_reserved id -> + | Id (pos, id) when env.inside_ppl_class && SN.PPLFunctions.is_reserved id -> let m = (pos, String_utils.lstrip id "\\") in (* Mock these as type equivalent to \Infer -> sample... *) let infer_e = CI (p, "\\Infer") in @@ -4141,11 +4141,11 @@ and call_parent_construct pos env el uel = make_call env te tal tel tuel ty and fun_type_of_id env x tal = - match Env.get_fun env (snd x) with + match get_fun env (snd x) with | None -> let env, _, ty = unbound_name env x (Pos.none, Aast.Null) in env, ty | Some decl_fty -> let ety_env = Phase.env_with_self env in - let tal = List.map ~f:(Decl_hint.hint env.Env.decl_env) tal in + let tal = List.map ~f:(Decl_hint.hint env.decl_env) tal in let decl_fty = Typing_enforceability.compute_enforced_and_pessimize_fun_type_simple env decl_fty in let env, fty = Phase.(localize_ft @@ -4305,7 +4305,7 @@ and class_get_ ~is_method ~is_const ~this_ty ~coerce_from_ty ?(explicit_tparams= (* We special case Tfun here to allow passing in explicit tparams to localize_ft. *) | r, Tfun ft when is_method -> let explicit_targs = List.map explicit_tparams - ~f:(Decl_hint.hint env.Env.decl_env) in + ~f:(Decl_hint.hint env.decl_env) in let ft = Typing_enforceability.compute_enforced_and_pessimize_fun_type_simple env ft in let env, ft = Phase.(localize_ft ~instantiation: { use_name=strip_ns mid; use_pos=p; explicit_targs } @@ -4560,7 +4560,7 @@ and obj_get_concrete_ty ~inst_meth ~is_method ~coerce_from_ty ?(explicit_tparams | (r, Tfun ft) when is_method -> (* We special case function types here to be able to pass explicit type * parameters. *) - let explicit_targs = List.map ~f:(Decl_hint.hint env.Env.decl_env) explicit_tparams in + let explicit_targs = List.map ~f:(Decl_hint.hint env.decl_env) explicit_tparams in let ft = Typing_enforceability.compute_enforced_and_pessimize_fun_type_simple env ft in let env, ft = Phase.(localize_ft ~instantiation:{ use_name=strip_ns id_str; use_pos=id_pos; explicit_targs } @@ -5341,7 +5341,7 @@ and call ~(expected: ExpectedTy.t option) ?method_call_info pos env fty el uel = | None -> Errors.anonymous_recursive_call pos; env, (tel, tuel, err_witness env pos) - | Some { Env. rx = reactivity ; is_coroutine; counter = ftys; typecheck = anon; _ } -> + | Some { rx = reactivity ; is_coroutine; counter = ftys; typecheck = anon; _ } -> let () = check_arity pos fpos (Typing_defs.arity_min call_arity) arity in let tyl = List.map tyl TUtils.default_fun_param in let env, _, ty = anon ~el env tyl call_arity in @@ -5750,7 +5750,7 @@ and refine_lvalue_type env ((_p, ty), _ as te) ~refine = set_local env local ty | None -> env -and condition_nullity ~nonnull (env: Env.env) te = +and condition_nullity ~nonnull (env: env) te = match te with (* assignment: both the rhs and lhs of the '=' must be made null/non-null *) | _, T.Binop (Ast_defs.Eq None, var, te) -> @@ -6084,7 +6084,7 @@ and string2 env idl = (* If the current class inherits from classes that take type arguments, we need * to check that the arguments provided are consistent with the constraints on * the type parameters. *) -and check_implements_tparaml (env: Env.env) ht = +and check_implements_tparaml (env: env) ht = (* Pessimize `extends C to extends C<~int>` for erased generics so that the lower bound of * dynamic is respected *) let ht = @@ -6128,7 +6128,7 @@ and class_def_parent env class_def class_type = | (_, Happly ((_, x), _) as parent_ty) :: _ -> Option.iter (Env.get_class_dep env x) ~f:(check_parent class_def class_type); - let parent_ty = Decl_hint.hint env.Env.decl_env parent_ty in + let parent_ty = Decl_hint.hint env.decl_env parent_ty in env, Some x, parent_ty (* The only case where we have more than one parent class is when * dealing with interfaces and interfaces cannot use parent. @@ -6236,15 +6236,15 @@ and class_def_ env c tc = Sequence.iter (Cls.smethods tc) (check_override ~is_static:true); end; let env = - { env with Env.inside_ppl_class = + { env with inside_ppl_class = Attributes.mem SN.UserAttributes.uaProbabilisticModel c.c_user_attributes } in let pc, _ = c.c_name in let impl = List.map (c.c_extends @ c.c_implements @ c.c_uses) - (Decl_hint.hint env.Env.decl_env) in + (Decl_hint.hint env.decl_env) in let c_tparam_list : decl tparam list = List.map c.c_tparams.c_tparam_list - ~f:(Decl_hint.aast_tparam_to_decl_tparam env.Env.decl_env) in + ~f:(Decl_hint.aast_tparam_to_decl_tparam env.decl_env) in let env, constraints = Phase.localize_generic_parameters_with_bounds env c_tparam_list ~ety_env:(Phase.env_with_self env) in @@ -6507,7 +6507,7 @@ and class_const_def env cc = }, ty) and class_constr_def env constructor = - let env = { env with Env.inside_constructor = true } in + let env = { env with inside_constructor = true } in Option.bind constructor (method_def env) and class_implements_type env c1 removals ctype2 = @@ -6528,7 +6528,7 @@ and class_var_def ~is_static env cv = | None -> env, None | Some (p, _ as cty) -> - let decl_cty = Decl_hint.hint env.Env.decl_env cty in + let decl_cty = Decl_hint.hint env.decl_env cty in let env, cty = Phase.localize_with_self_possibly_enforceable env decl_cty in env, Some (ExpectedTy.make_and_allow_coercion p Reason.URhint cty) in (* Next check the expression, passing in expected type if present *) @@ -6677,7 +6677,7 @@ and method_def env m = let env = Env.set_env_function_pos env pos in let env = Typing_attributes.check_def env new_object SN.AttributeKinds.mthd m.m_user_attributes in - let reactive = fun_reactivity env.Env.decl_env m.m_user_attributes m.m_params in + let reactive = fun_reactivity env.decl_env m.m_user_attributes m.m_params in let mut = match TUtils.fun_mutable m.m_user_attributes with | None -> @@ -6691,7 +6691,7 @@ and method_def env m = let ety_env = { (Phase.env_with_self env) with from_class = Some CIstatic; } in let m_tparams : decl tparam list = List.map m.m_tparams - ~f:(Decl_hint.aast_tparam_to_decl_tparam env.Env.decl_env) in + ~f:(Decl_hint.aast_tparam_to_decl_tparam env.decl_env) in let env, constraints = Phase.localize_generic_parameters_with_bounds env m_tparams ~ety_env:ety_env in @@ -6710,7 +6710,7 @@ and method_def env m = then Env.set_using_var env this else env in let env = Env.clear_params env in - let decl_ty = Option.map ~f:(Decl_hint.hint env.Env.decl_env) (hint_of_type_hint m.m_ret) in + let decl_ty = Option.map ~f:(Decl_hint.hint env.decl_env) (hint_of_type_hint m.m_ret) in let env = Env.set_fn_kind env m.m_fun_kind in let env, locl_ty = match decl_ty with | None -> @@ -6800,7 +6800,7 @@ and typedef_def tcopt typedef = let tdecl = Env.get_typedef env (snd typedef.t_name) in add_decl_errors (Option.(map tdecl (fun tdecl -> value_exn tdecl.td_decl_errors))); let t_tparams : decl tparam list = List.map typedef.t_tparams - ~f:(Decl_hint.aast_tparam_to_decl_tparam env.Env.decl_env) in + ~f:(Decl_hint.aast_tparam_to_decl_tparam env.decl_env) in let env, constraints = Phase.localize_generic_parameters_with_bounds env t_tparams ~ety_env:(Phase.env_with_self env) in @@ -6817,11 +6817,11 @@ and typedef_def tcopt typedef = t_mode = _; t_namespace = _; } = typedef in - let ty = Decl_hint.hint env.Env.decl_env hint in + let ty = Decl_hint.hint env.decl_env hint in let env, ty = Phase.localize_with_self env ty in let env = begin match tcstr with | Some tcstr -> - let cstr = Decl_hint.hint env.Env.decl_env tcstr in + let cstr = Decl_hint.hint env.decl_env tcstr in let env, cstr = Phase.localize_with_self env cstr in Typing_ops.sub_type t_pos Reason.URnewtype_cstr env ty cstr Errors.newtype_alias_must_satisfy_constraint @@ -6859,7 +6859,7 @@ and gconst_def tcopt cst = let value = cst.cst_value in match cst.cst_type with | Some hint -> - let ty = Decl_hint.hint env.Env.decl_env hint in + let ty = Decl_hint.hint env.decl_env hint in let env, dty = Phase.localize_with_self env ty in let env, te, value_type = let expected = ExpectedTy.make (fst hint) Reason.URhint dty in diff --git a/hphp/hack/src/typing/typing_arrays.ml b/hphp/hack/src/typing/typing_arrays.ml index b6361d24f77..923e1169e8a 100644 --- a/hphp/hack/src/typing/typing_arrays.ml +++ b/hphp/hack/src/typing/typing_arrays.ml @@ -10,6 +10,7 @@ open Core_kernel open Common open Typing_defs +open Typing_env_types open Type_mapper module Env = Typing_env diff --git a/hphp/hack/src/typing/typing_debug.ml b/hphp/hack/src/typing/typing_debug.ml index 51b1d6a80da..788d121b791 100644 --- a/hphp/hack/src/typing/typing_debug.ml +++ b/hphp/hack/src/typing/typing_debug.ml @@ -1,3 +1,5 @@ +open Typing_env_types + module Env = Typing_env module Log = Typing_log module TySet = Typing_set @@ -13,8 +15,8 @@ let ty_set_size env tyset = let tvenv_size env = IMap.fold - (fun _ { Env.lower_bounds; Env.upper_bounds; _ } size -> - size + ty_set_size env lower_bounds + ty_set_size env upper_bounds) env.Env.tvenv 0 + (fun _ { lower_bounds; upper_bounds; _ } size -> + size + ty_set_size env lower_bounds + ty_set_size env upper_bounds) env.tvenv 0 let env_size env = local_env_size env + @@ -22,7 +24,7 @@ let env_size env = let log_env_if_too_big pos env = if (Env.get_tcopt env).GlobalOptions.tco_timeout > 0 - && List.length !(env.Env.big_envs) < 1 + && List.length !(env.big_envs) < 1 && env_size env >= 1000 then - env.Env.big_envs := (pos, env) :: !(env.Env.big_envs) + env.big_envs := (pos, env) :: !(env.big_envs) diff --git a/hphp/hack/src/typing/typing_enforceability.ml b/hphp/hack/src/typing/typing_enforceability.ml index f215a0eecca..27885e768d8 100644 --- a/hphp/hack/src/typing/typing_enforceability.ml +++ b/hphp/hack/src/typing/typing_enforceability.ml @@ -9,6 +9,7 @@ open Core_kernel open Typing_defs +open Typing_env_types module Cls = Decl_provider.Class module MakeType = Typing_make_type @@ -155,7 +156,7 @@ and pessimize_fun_type env (ft: decl fun_type) = ft_tparams; } -let rec is_enforceable (env: Env.env) (ty: decl ty) = +let rec is_enforceable (env: env) (ty: decl ty) = match snd ty with | Tthis -> false | Tapply ((_, name), _) when Env.is_enum env name -> false @@ -237,7 +238,7 @@ let is_enforced env ty = enforceable && not is_hhi let pessimize_type_simple env (ty: decl ty) = - if not env.Env.pessimize then ty else + if not env.pessimize then ty else match ty with | _, Tprim (Aast.Tvoid | Aast.Tnoreturn) -> ty | _ -> wrap_like ty diff --git a/hphp/hack/src/typing/typing_env.ml b/hphp/hack/src/typing/typing_env.ml index 5c9e6396921..c4cff4f2785 100644 --- a/hphp/hack/src/typing/typing_env.ml +++ b/hphp/hack/src/typing/typing_env.ml @@ -9,7 +9,7 @@ open Core_kernel open Common -include Typing_env_types +open Typing_env_types open Decl_env open Typing_defs open Aast @@ -23,6 +23,7 @@ module C = Typing_continuations module TL = Typing_logic module Cls = Decl_provider.Class module Fake = Typing_fake_members +module TPEnv = Type_parameter_env let show_env _ = "" let pp_env _ _ = Printf.printf "%s\n" "" @@ -507,9 +508,6 @@ let set_condition_type env n ty = let get_condition_type env n = SMap.get n env.genv.condition_types -let env_reactivity env = - env.lenv.local_reactive - (* Some form (strict/shallow/local) of reactivity *) let env_local_reactive env = env_reactivity env <> Nonreactive @@ -710,11 +708,6 @@ let get_fn_kind env = env.genv.fun_kind let get_file env = env.genv.file -let get_fun env x = - let dep = Dep.Fun x in - Option.iter env.decl_env.droot (fun root -> Typing_deps.add_idep root dep); - Decl_provider.get_fun x - let set_fn_kind env fn_type = let genv = env.genv in let genv = { genv with fun_kind = fn_type } in diff --git a/hphp/hack/src/typing/typing_env.mli b/hphp/hack/src/typing/typing_env.mli index db1dd6c5123..0a6174a8480 100644 --- a/hphp/hack/src/typing/typing_env.mli +++ b/hphp/hack/src/typing/typing_env.mli @@ -6,8 +6,7 @@ * LICENSE file in the "hack" directory of this source tree. * *) -include Typing_env_types_sig.S - +open Typing_env_types open Decl_provider open Typing_defs @@ -70,7 +69,6 @@ val get_parent_id : env -> string val get_parent : env -> decl ty val get_fn_kind : env -> Ast_defs.fun_kind val get_file : env -> Relative_path.t -val get_fun : env -> fun_key -> fun_decl option val set_fn_kind : env -> Ast_defs.fun_kind -> env val set_inside_ppl_class : env -> bool -> env val add_anonymous : env -> anon -> env * int @@ -184,7 +182,6 @@ val get_tpenv_tparams : env -> SSet.t val set_env_reactive : env -> reactivity -> env val set_env_function_pos: env -> Pos.t -> env val set_env_pessimize: env -> env -val env_reactivity: env -> reactivity val env_local_reactive : env -> bool val add_mutable_var : env -> Local_id.t -> Typing_mutability_env.mutability -> env val local_is_mutable : include_borrowed: bool -> env -> Local_id.t -> bool diff --git a/hphp/hack/src/typing/typing_env_types.ml b/hphp/hack/src/typing/typing_env_types.ml index c1b0c964eb9..ae847631985 100644 --- a/hphp/hack/src/typing/typing_env_types.ml +++ b/hphp/hack/src/typing/typing_env_types.ml @@ -15,6 +15,8 @@ module TySet = Typing_set type locl_ty = locl ty +[@@@warning "-32"] + let show_local_id_set_t _ = "" let pp_local_id_set_t _ _ = Printf.printf "%s\n" "" type local_id_set_t = Local_id.Set.t @@ -46,6 +48,8 @@ let pp_anon _ _ = Printf.printf "%s\n" "" let show_tfun _ = "" let pp_tfun _ _ = Printf.printf "%s\n" "" +[@@@warning "+32"] + type tyvar_info = { (* Where was the type variable introduced? (e.g. generic method invocation, * new object construction) @@ -146,3 +150,11 @@ and anon = { locl fun_arity -> env * Tast.expr * locl_ty; } + +let get_fun env x = + let dep = Typing_deps.Dep.Fun x in + Option.iter env.decl_env.Decl_env.droot (fun root -> Typing_deps.add_idep root dep); + Decl_provider.get_fun x + +let env_reactivity env = + env.lenv.local_reactive diff --git a/hphp/hack/src/typing/typing_env_types_sig.mli b/hphp/hack/src/typing/typing_env_types.mli similarity index 96% rename from hphp/hack/src/typing/typing_env_types_sig.mli rename to hphp/hack/src/typing/typing_env_types.mli index 51269b6851c..c650118e1bc 100644 --- a/hphp/hack/src/typing/typing_env_types_sig.mli +++ b/hphp/hack/src/typing/typing_env_types.mli @@ -9,7 +9,6 @@ open Typing_defs module TySet = Typing_set - module type S = sig (* Local environment includes types of locals and bounds on type parameters. *) type local_env = { @@ -101,4 +100,5 @@ and anon = { env * Tast.expr * locl ty; } -end +val get_fun : env -> Decl_provider.fun_key -> Decl_provider.fun_decl option +val env_reactivity: env -> reactivity diff --git a/hphp/hack/src/typing/typing_expand.mli b/hphp/hack/src/typing/typing_expand.mli index f208dfa7b2b..c185206b6dc 100644 --- a/hphp/hack/src/typing/typing_expand.mli +++ b/hphp/hack/src/typing/typing_expand.mli @@ -18,6 +18,6 @@ (*****************************************************************************) val fully_expand: - Typing_env.env -> + Typing_env_types.env -> Typing_defs.locl Typing_defs.ty -> Typing_defs.locl Typing_defs.ty diff --git a/hphp/hack/src/typing/typing_extends.mli b/hphp/hack/src/typing/typing_extends.mli index bfc154d92ec..ca04535c2e9 100644 --- a/hphp/hack/src/typing/typing_extends.mli +++ b/hphp/hack/src/typing/typing_extends.mli @@ -14,7 +14,7 @@ open Core_kernel val check_implements: - Typing_env.env -> + Typing_env_types.env -> string list String.Map.t -> Typing_defs.decl Typing_defs.ty -> Typing_defs.decl Typing_defs.ty -> unit diff --git a/hphp/hack/src/typing/typing_exts.ml b/hphp/hack/src/typing/typing_exts.ml index 2e6e2d22de7..8b7f08091ed 100644 --- a/hphp/hack/src/typing/typing_exts.ml +++ b/hphp/hack/src/typing/typing_exts.ml @@ -29,6 +29,7 @@ Ad-hoc rules for typing some common idioms open Core_kernel open Typing_defs +open Typing_env_types open Aast module Env = Typing_env @@ -47,8 +48,8 @@ let magic_method_name input = else if phys_equal c uc then "format_upcase_" ^ String.make 1 lc else "format_" ^ String.make 1 lc -let lookup_magic_type (env:Env.env) (class_:locl ty) (fname:string) : - Env.env * (locl fun_params * locl ty option) option = +let lookup_magic_type (env:env) (class_:locl ty) (fname:string) : + env * (locl fun_params * locl ty option) option = match class_ with | (_, Tunion [ (_, Tdynamic); @@ -83,13 +84,13 @@ let lookup_magic_type (env:Env.env) (class_:locl ty) (fname:string) : let get_char s i = if i >= String.length s then None else Some (String.get s i) -let parse_printf_string env s pos (class_:locl ty) : Env.env * locl fun_params = - let rec read_text env i : Env.env * locl fun_params = +let parse_printf_string env s pos (class_:locl ty) : env * locl fun_params = + let rec read_text env i : env * locl fun_params = match get_char s i with | Some '%' -> read_modifier env (i+1) class_ i | Some _ -> read_text env (i+1) | None -> env, [] - and read_modifier env i class_ i0 : Env.env * locl fun_params = + and read_modifier env i class_ i0 : env * locl fun_params = let fname = magic_method_name (get_char s i) in let snippet = String.sub s i0 ((min (i+1) (String.length s)) - i0) in let add_reason = List.map ~f:begin fun p -> @@ -125,7 +126,7 @@ let mapM (f:'s->'x->'s*'y) : 'st -> 'x list -> 's * 'y list = (* If expr is a constant string, that string, otherwise a position where it is obviously not *) -let rec const_string_of (env:Env.env) (e:Nast.expr) : Env.env * (Pos.t, string) either = +let rec const_string_of (env:env) (e:Nast.expr) : env * (Pos.t, string) either = let glue x y = match x,y with | Right sx, Right sy -> Right (sx^sy) | Left p, _ -> Left p @@ -144,8 +145,8 @@ let rec const_string_of (env:Env.env) (e:Nast.expr) : Env.env * (Pos.t, string) | p, _ -> env, Left p (* Specialize a function type using whatever we can tell about the args *) -let retype_magic_func (env:Env.env) (ft:locl fun_type) (el:Nast.expr list) : Env.env * locl fun_type = - let rec f env param_types args : Env.env * locl fun_params option = +let retype_magic_func (env:env) (ft:locl fun_type) (el:Nast.expr list) : env * locl fun_type = + let rec f env param_types args : env * locl fun_params option = (match param_types, args with | [ { fp_type = { et_type = (_, Toption (_, Tclass ((_, fs), _, [_]))); _ }; _}], [(_, Null)] when SN.Classes.is_format_string fs -> env, None diff --git a/hphp/hack/src/typing/typing_generic_constraint.ml b/hphp/hack/src/typing/typing_generic_constraint.ml index 2b61df37886..7d6f1a30df7 100644 --- a/hphp/hack/src/typing/typing_generic_constraint.ml +++ b/hphp/hack/src/typing/typing_generic_constraint.ml @@ -12,6 +12,7 @@ module TUtils = Typing_utils module Reason = Typing_reason module Env = Typing_env open Typing_defs +open Typing_env_types let check_constraint env ck ty ~cstr_ty = Typing_log.(log_with_level env "sub" 1 (fun () -> @@ -45,7 +46,7 @@ let check_constraint env ck ty ~cstr_ty = * constraint type. *) TUtils.sub_type env ecstr_ty ty Errors.unify_error -let add_check_constraint_todo (env:Env.env) ~use_pos (pos,name) ck cstr_ty ty = +let add_check_constraint_todo (env:env) ~use_pos (pos,name) ck cstr_ty ty = Errors.try_ (fun () -> check_constraint env ck ty ~cstr_ty) @@ -54,7 +55,7 @@ let add_check_constraint_todo (env:Env.env) ~use_pos (pos,name) ck cstr_ty ty = env ) -let add_check_where_constraint_todo ~in_class (env:Env.env) ~use_pos ~definition_pos ck cstr_ty ty = +let add_check_where_constraint_todo ~in_class (env:env) ~use_pos ~definition_pos ck cstr_ty ty = Errors.try_ (fun () -> check_constraint env ck ty ~cstr_ty) @@ -103,7 +104,7 @@ let handle_eq_tconst_constraint env ck ty cstr_ty = end let add_check_tconst_where_constraint_todo - (env:Env.env) ~use_pos ~definition_pos ck ty_from_env cstr_ty ty = + (env:env) ~use_pos ~definition_pos ck ty_from_env cstr_ty ty = Errors.try_ (fun () -> let env, ty = ty_from_env env ty in diff --git a/hphp/hack/src/typing/typing_intersection.mli b/hphp/hack/src/typing/typing_intersection.mli index 93c2f6f7707..4e99f1b164c 100644 --- a/hphp/hack/src/typing/typing_intersection.mli +++ b/hphp/hack/src/typing/typing_intersection.mli @@ -8,13 +8,13 @@ *) open Typing_defs +open Typing_env_types -module Env = Typing_env module Reason = Typing_reason module Utils = Typing_utils -val non : Env.env -> Reason.t -> locl ty -> approx:Utils.approx-> Env.env * locl ty -val intersect : Env.env -> r:Reason.t -> locl ty -> locl ty -> Env.env * locl ty -val intersect_list : Env.env -> Reason.t -> locl ty list -> Env.env * locl ty -val simplify_intersections : Env.env -> ?on_tyvar:(Env.env -> Reason.t -> int -> Env.env * locl ty) - -> locl ty -> Env.env * locl ty +val non : env -> Reason.t -> locl ty -> approx:Utils.approx-> env * locl ty +val intersect : env -> r:Reason.t -> locl ty -> locl ty -> env * locl ty +val intersect_list : env -> Reason.t -> locl ty list -> env * locl ty +val simplify_intersections : env -> ?on_tyvar:(env -> Reason.t -> int -> env * locl ty) + -> locl ty -> env * locl ty diff --git a/hphp/hack/src/typing/typing_lenv.ml b/hphp/hack/src/typing/typing_lenv.ml index 41e7585d011..dba7a01af85 100644 --- a/hphp/hack/src/typing/typing_lenv.ml +++ b/hphp/hack/src/typing/typing_lenv.ml @@ -9,7 +9,7 @@ open Core_kernel module Env = Typing_env -open Typing_env +open Typing_env_types module C = Typing_continuations module LEnvC = Typing_per_cont_env module LEnvOps = Typing_per_cont_ops @@ -122,7 +122,7 @@ let union_lenvs_ env parent_lenv lenv1 lenv2 = parent_lenv.local_mutability lenv1.local_mutability lenv2.local_mutability in let local_reactive = merge_reactivity parent_lenv lenv1 lenv2 in let env = union_by_cont env lenv1 lenv2 in - let lenv = { env.Env.lenv with + let lenv = { env.lenv with local_using_vars; local_mutability; local_reactive; diff --git a/hphp/hack/src/typing/typing_lenv.mli b/hphp/hack/src/typing/typing_lenv.mli index 6de7dd8ad46..8e7223c48eb 100644 --- a/hphp/hack/src/typing/typing_lenv.mli +++ b/hphp/hack/src/typing/typing_lenv.mli @@ -6,71 +6,72 @@ * LICENSE file in the "hack" directory of this source tree. * *) +open Typing_env_types (*****************************************************************************) (* Functions dealing with old style local environment *) (*****************************************************************************) val get_all_locals : - Typing_env.env -> Typing_per_cont_env.t + env -> Typing_per_cont_env.t val get_cont_option : - Typing_env.env -> + env -> Typing_continuations.t -> Typing_per_cont_env.per_cont_entry option val drop_cont : - Typing_env.env -> - Typing_continuations.t -> Typing_env.env + env -> + Typing_continuations.t -> env val drop_conts : - Typing_env.env -> - Typing_continuations.t list -> Typing_env.env + env -> + Typing_continuations.t list -> env val replace_cont : - Typing_env.env -> + env -> Typing_continuations.t -> - Typing_per_cont_env.per_cont_entry option -> Typing_env.env + Typing_per_cont_env.per_cont_entry option -> env val restore_conts_from : - Typing_env.env -> + env -> Typing_per_cont_env.t -> - Typing_continuations.t list -> Typing_env.env + Typing_continuations.t list -> env val restore_and_merge_conts_from : - Typing_env.env -> + env -> Typing_per_cont_env.t -> - Typing_continuations.t list -> Typing_env.env + Typing_continuations.t list -> env val update_next_from_conts : - Typing_env.env -> - Typing_continuations.t list -> Typing_env.env + env -> + Typing_continuations.t list -> env val save_and_merge_next_in_cont : - Typing_env.env -> - Typing_continuations.t -> Typing_env.env + env -> + Typing_continuations.t -> env val move_and_merge_next_in_cont : - Typing_env.env -> - Typing_continuations.t -> Typing_env.env + env -> + Typing_continuations.t -> env val union: - Typing_env.env -> + env -> Typing_local_types.local -> Typing_local_types.local -> - Typing_env.env * Typing_local_types.local + env * Typing_local_types.local val union_by_cont : - Typing_env.env -> - Typing_env.local_env -> - Typing_env.local_env -> Typing_env.env + env -> + local_env -> + local_env -> env val union_contextopts : - Typing_env.env -> + env -> Typing_per_cont_env.per_cont_entry option -> Typing_per_cont_env.per_cont_entry option -> - Typing_env.env * Typing_per_cont_env.per_cont_entry option + env * Typing_per_cont_env.per_cont_entry option val union_lenvs : - Typing_env.env -> - Typing_env.local_env -> - Typing_env.local_env -> - Typing_env.local_env -> Typing_env.env + env -> + local_env -> + local_env -> + local_env -> env val union_lenv_list : - Typing_env.env -> - Typing_env.local_env -> - Typing_env.local_env list -> Typing_env.env + env -> + local_env -> + local_env list -> env val union_envs : - Typing_env.env -> - Typing_env.env -> - Typing_env.env -> - Typing_env.env + env -> + env -> + env -> + env (* When entering control flow structures, some * preexisting continuations must be stashed away and then restored * on exiting those control flow structures. @@ -79,11 +80,11 @@ val union_envs : * continuations from any enclosing loops must be stashed away so as not to * interfere with them. *) val stash_and_do : - Typing_env.env -> + env -> Typing_continuations.t list -> - (Typing_env.env -> - Typing_env.env * 'a) -> Typing_env.env * 'a + (env -> + env * 'a) -> env * 'a val env_with_empty_fakes : - Typing_env.env -> Typing_env.env + env -> env val has_next : - Typing_env.env -> bool + env -> bool diff --git a/hphp/hack/src/typing/typing_log.ml b/hphp/hack/src/typing/typing_log.ml index 9b2ab3bb2b9..c1db73355e4 100644 --- a/hphp/hack/src/typing/typing_log.ml +++ b/hphp/hack/src/typing/typing_log.ml @@ -9,10 +9,11 @@ open Core_kernel open Typing_defs +open Typing_env_types module Env = Typing_env module Pr = Typing_print +module TPEnv = Type_parameter_env module TySet = Typing_set -open Env open Tty open Typing_log_value diff --git a/hphp/hack/src/typing/typing_memoize.ml b/hphp/hack/src/typing/typing_memoize.ml index e33f70ae34c..5f38e3b9a04 100644 --- a/hphp/hack/src/typing/typing_memoize.ml +++ b/hphp/hack/src/typing/typing_memoize.ml @@ -9,20 +9,21 @@ open Core_kernel open Aast open Typing_defs +open Typing_env_types module Env = Typing_env module SN = Naming_special_names module SubType = Typing_subtype module MakeType = Typing_make_type -let check_param : Env.env -> Nast.fun_param -> unit = +let check_param : env -> Nast.fun_param -> unit = fun env {param_type_hint; param_pos; _} -> let error ty = let ty_str = Typing_print.error env ty in let msgl = Reason.to_string ("This is "^ty_str) (fst ty) in Errors.invalid_memoized_param param_pos msgl in - let rec check_memoizable: Env.env -> locl ty -> unit = + let rec check_memoizable: env -> locl ty -> unit = fun env ty -> let env, ty = Env.expand_type env ty in let ety_env = Typing_phase.env_with_self env in @@ -100,7 +101,7 @@ let check_param : Env.env -> Nast.fun_param -> unit = let env, ty = Typing_phase.localize_hint_with_self env hint in check_memoizable env ty -let check: Env.env -> Nast.user_attribute list -> +let check: env -> Nast.user_attribute list -> Nast.fun_param list -> Nast.fun_variadicity -> unit = fun env user_attributes params variadic -> if Attributes.mem SN.UserAttributes.uaMemoize user_attributes || @@ -113,10 +114,10 @@ let check: Env.env -> Nast.user_attribute list -> | FVnonVariadic -> () end -let check_function: Env.env -> Nast.fun_ -> unit = +let check_function: env -> Nast.fun_ -> unit = fun env {f_user_attributes; f_params; f_variadic; _ } -> check env f_user_attributes f_params f_variadic -let check_method: Env.env -> Nast.method_ -> unit = +let check_method: env -> Nast.method_ -> unit = fun env {m_user_attributes; m_params; m_variadic; _ } -> check env m_user_attributes m_params m_variadic diff --git a/hphp/hack/src/typing/typing_memoize.mli b/hphp/hack/src/typing/typing_memoize.mli index b8ea79c156c..3f9944b7da2 100644 --- a/hphp/hack/src/typing/typing_memoize.mli +++ b/hphp/hack/src/typing/typing_memoize.mli @@ -11,5 +11,5 @@ * Checks if a function/method can be memoized. If the function cannot be * memoized this will add an error to the gloabl error list *) -val check_function: Typing_env.env -> Nast.fun_ -> unit -val check_method: Typing_env.env -> Nast.method_ -> unit +val check_function: Typing_env_types.env -> Nast.fun_ -> unit +val check_method: Typing_env_types.env -> Nast.method_ -> unit diff --git a/hphp/hack/src/typing/typing_mutability.ml b/hphp/hack/src/typing/typing_mutability.ml index ee91e2280cd..0512f8aca4f 100644 --- a/hphp/hack/src/typing/typing_mutability.ml +++ b/hphp/hack/src/typing/typing_mutability.ml @@ -47,14 +47,14 @@ let is_fun_call_returning_mutable (env : Env.env) (e : Tast.expr): bool = | _ -> false end -include Shared(Env) +include Shared(Typing_env_types) let handle_value_in_return ~function_returns_mutable ~function_returns_void_for_rx - (env: Env.env) + (env: Typing_env_types.env) fun_pos - (e: Tast.expr): Env.env = + (e: Tast.expr): Typing_env_types.env = let error_mutable e mut_opt = let kind = match mut_opt with @@ -122,11 +122,11 @@ let handle_value_in_return aux e let freeze_or_move_local (p : Pos.t) - (env : Typing_env.env) + (env : Typing_env_types.env) (tel : Tast.expr list) (invalid_target : Pos.t -> Pos.t -> string -> unit) (invalid_use : Pos.t -> unit) - : Typing_env.env = + : Typing_env_types.env = match tel with | [_, T.Any] -> env | [(_, T.Lvar (id_pos, id));] -> @@ -152,17 +152,17 @@ let freeze_or_move_local let freeze_local (p : Pos.t) - (env : Typing_env.env) + (env : Typing_env_types.env) (tel : Tast.expr list) - : Typing_env.env = + : Typing_env_types.env = freeze_or_move_local p env tel Errors.invalid_freeze_target Errors.invalid_freeze_use let move_local (p : Pos.t) - (env : Typing_env.env) + (env : Typing_env_types.env) (tel : Tast.expr list) - : Typing_env.env = + : Typing_env_types.env = freeze_or_move_local p env tel Errors.invalid_move_target Errors.invalid_move_use @@ -175,8 +175,8 @@ let rec is_move_or_mutable_call ?(allow_move=true) te = (* Checks for assignment errors as a pass on the TAST *) let handle_assignment_mutability - (env : Typing_env.env) (te1 : Tast.expr) (te2 : Tast.expr_ option) - : Typing_env.env = + (env : Typing_env_types.env) (te1 : Tast.expr) (te2 : Tast.expr_ option) + : Typing_env_types.env = (* If e2 is a mutable expression, then e1 is added to the mutability env *) let mut_env = Env.get_env_mutability env in let mut_env = match snd te1, te2 with diff --git a/hphp/hack/src/typing/typing_mutability.mli b/hphp/hack/src/typing/typing_mutability.mli index 73d80eb086b..969ee0b50e2 100644 --- a/hphp/hack/src/typing/typing_mutability.mli +++ b/hphp/hack/src/typing/typing_mutability.mli @@ -18,17 +18,17 @@ module Shared(Env: Env_S): sig end val handle_assignment_mutability : - Typing_env.env -> + Typing_env_types.env -> Tast.expr -> Tast.expr_ option -> - Typing_env.env -val freeze_local : Pos.t -> Typing_env.env -> Tast.expr list -> Typing_env.env -val move_local : Pos.t -> Typing_env.env -> Tast.expr list -> Typing_env.env + Typing_env_types.env +val freeze_local : Pos.t -> Typing_env_types.env -> Tast.expr list -> Typing_env_types.env +val move_local : Pos.t -> Typing_env_types.env -> Tast.expr list -> Typing_env_types.env val handle_value_in_return: function_returns_mutable: bool -> function_returns_void_for_rx: bool -> - Typing_env.env -> + Typing_env_types.env -> Pos.t -> Tast.expr -> - Typing_env.env + Typing_env_types.env val is_move_or_mutable_call: ?allow_move: bool -> Tast.expr_ -> bool diff --git a/hphp/hack/src/typing/typing_per_cont_ops.mli b/hphp/hack/src/typing/typing_per_cont_ops.mli index 8339eabbd39..9a3c593613f 100644 --- a/hphp/hack/src/typing/typing_per_cont_ops.mli +++ b/hphp/hack/src/typing/typing_per_cont_ops.mli @@ -10,6 +10,7 @@ (*****************************************************************************) (* Functions dealing with continuation based flow typing of local variables *) (*****************************************************************************) +open Typing_env_types module Env = Typing_env module C = Typing_continuations @@ -39,11 +40,11 @@ type 'a locals_merge_fn = * used after typechecking a try-catch-finally statement, as continuations * may be used outside of this statement *) val restore_and_merge_conts_from : - Env.env -> - Env.env locals_merge_fn -> + env -> + env locals_merge_fn -> LEnvC.t -> from:LEnvC.t -> - C.t list -> Env.env * LEnvC.t + C.t list -> env * LEnvC.t (* Merge all continuations in the provided list and update the next * continuation with the result. @@ -53,10 +54,10 @@ val restore_and_merge_conts_from : * continuation, or at the beginning of a loop block, we merge the 'continue' * continuation into the 'next' continuation. *) val update_next_from_conts : - Env.env -> - Env.env locals_merge_fn -> + env -> + env locals_merge_fn -> LEnvC.t -> - C.Map.key list -> Env.env * LEnvC.t + C.Map.key list -> env * LEnvC.t (* After this call, the provided continuation will be the union of * itself and the next continuation. @@ -67,10 +68,10 @@ val update_next_from_conts : * continuation. *) val save_and_merge_next_in_cont : - Env.env -> - Env.env locals_merge_fn -> + env -> + env locals_merge_fn -> LEnvC.t -> - C.Map.key -> Env.env * LEnvC.t + C.Map.key -> env * LEnvC.t (* union the provided continuation with the next continuation and store * the result in the provided continuation. Finally, remove the next @@ -81,10 +82,10 @@ val save_and_merge_next_in_cont : * continuation by "merging" it into the 'continue' continuation. *) val move_and_merge_next_in_cont : - Env.env -> - Env.env locals_merge_fn -> + env -> + env locals_merge_fn -> LEnvC.t -> - C.Map.key -> Env.env * LEnvC.t + C.Map.key -> env * LEnvC.t (* Unions two context options. We call "context" here a map from locals to * types. @@ -103,10 +104,10 @@ val move_and_merge_next_in_cont : * union context1 context2 = { y: (B|D) } *) val union_opts : - Env.env locals_merge_fn -> - Env.env -> + env locals_merge_fn -> + env -> LEnvC.per_cont_entry option -> - LEnvC.per_cont_entry option -> Env.env * LEnvC.per_cont_entry option + LEnvC.per_cont_entry option -> env * LEnvC.per_cont_entry option (* union all continuations pairwise from two continuation maps. * This is used at certain merge points in the control flow, @@ -131,7 +132,7 @@ val union_opts : * } *) val union_by_cont : - Env.env -> - Env.env locals_merge_fn -> + env -> + env locals_merge_fn -> LEnvC.t -> - LEnvC.t -> Env.env * LEnvC.t + LEnvC.t -> env * LEnvC.t diff --git a/hphp/hack/src/typing/typing_phase.ml b/hphp/hack/src/typing/typing_phase.ml index 66967a0d036..35b621e9575 100644 --- a/hphp/hack/src/typing/typing_phase.ml +++ b/hphp/hack/src/typing/typing_phase.ml @@ -10,6 +10,7 @@ open Core_kernel open Common open Typing_defs +open Typing_env_types open Typing_dependent_type module Env = Typing_env @@ -75,8 +76,6 @@ module MakeType = Typing_make_type let decl ty = DeclTy ty let locl ty = LoclTy ty -type env = expand_env - type method_instantiation = { use_pos: Pos.t; @@ -305,7 +304,7 @@ and localize_cstr_ty ~ety_env env ty tp_name = and localize_ft ?(instantiation) ~ety_env env ft = (* set reactivity to Nonreactive to prevent occasional setting of condition types when expanding type constants *) - let saved_r = Env.env_reactivity env in + let saved_r = env_reactivity env in let env = Env.set_env_reactive env Nonreactive in (* If no explicit type parameters are provided, set the instantiated type parameter to * initially point to unresolved, so that it can grow and eventually be a subtype of @@ -353,7 +352,7 @@ and localize_ft ?(instantiation) ~ety_env env ft = end in (* restore reactivity *) let env = - if saved_r <> Env.env_reactivity env + if saved_r <> env_reactivity env then Env.set_env_reactive env saved_r else env in @@ -389,7 +388,7 @@ and localize_ft ?(instantiation) ~ety_env env ft = (* Grab and store the old tpenvs *) let old_tpenv = Env.get_tpenv env in - let old_global_tpenv = env.Env.global_tpenv in + let old_global_tpenv = env.global_tpenv in (* Always localize tparams so they are available for later Tast check *) let env, tparams = List.map_env env (fst ft.ft_tparams) localize_tparam in @@ -516,11 +515,11 @@ and localize_with_dty_validator env ty validate_dty = localize ~ety_env env ty and localize_hint_with_self env h = - let h = Decl_hint.hint env.Env.decl_env h in + let h = Decl_hint.hint env.decl_env h in localize_with_self env h and localize_hint ~ety_env env hint = - let hint_ty = Decl_hint.hint env.Env.decl_env hint in + let hint_ty = Decl_hint.hint env.decl_env hint in localize ~ety_env env hint_ty (* Add generic parameters to the environment, localize their bounds, and @@ -528,7 +527,7 @@ and localize_hint ~ety_env env hint = * where ck is as, super or = *) let localize_generic_parameters_with_bounds - ~ety_env (env:Env.env) (tparams:decl tparam list) = + ~ety_env (env:env) (tparams:decl tparam list) = let env = Env.add_generic_parameters env tparams in let localize_bound env ({ tp_name = (pos,name); tp_constraints = cstrl; _ }: decl tparam) = let tparam_ty = (Reason.Rwitness pos, Tabstract(AKgeneric name, None)) in @@ -539,12 +538,12 @@ let localize_generic_parameters_with_bounds env, List.concat cstrss let localize_where_constraints - ~ety_env (env:Env.env) where_constraints = + ~ety_env (env:env) where_constraints = let add_constraint env (h1, ck, h2) = let env, ty1 = - localize env (Decl_hint.hint env.Env.decl_env h1) ~ety_env in + localize env (Decl_hint.hint env.decl_env h1) ~ety_env in let env, ty2 = - localize env (Decl_hint.hint env.Env.decl_env h2) ~ety_env in + localize env (Decl_hint.hint env.decl_env h2) ~ety_env in TUtils.add_constraint (fst h1) env ck ty1 ty2 in List.fold_left where_constraints ~f:add_constraint ~init:env diff --git a/hphp/hack/src/typing/typing_phase.mli b/hphp/hack/src/typing/typing_phase.mli index d1e815c20f8..1565e6fef95 100644 --- a/hphp/hack/src/typing/typing_phase.mli +++ b/hphp/hack/src/typing/typing_phase.mli @@ -3,8 +3,7 @@ open Core_kernel open Common [@@@warning "+33"] open Typing_defs - -module Env = Typing_env +open Typing_env_types type method_instantiation = { @@ -13,62 +12,60 @@ type method_instantiation = explicit_targs: decl ty list; } -type env = expand_env - val env_with_self: - Env.env -> + env -> expand_env val localize_with_self: - Env.env -> + env -> decl ty -> - Env.env * locl ty + env * locl ty val localize_with_self_possibly_enforceable: - Env.env -> + env -> decl ty -> - Env.env * locl possibly_enforced_ty + env * locl possibly_enforced_ty val localize: ety_env:expand_env -> - Env.env -> + env -> decl ty -> - Env.env * locl ty + env * locl ty val localize_ft: ?instantiation:method_instantiation -> ety_env:expand_env -> - Env.env -> + env -> decl fun_type -> - Env.env * locl fun_type + env * locl fun_type val localize_hint_with_self: - Env.env -> + env -> Aast.hint -> - Env.env * locl ty + env * locl ty val localize_hint: ety_env:expand_env -> - Env.env -> + env -> Aast.hint -> - Env.env * locl ty + env * locl ty val localize_generic_parameters_with_bounds: ety_env:expand_env -> - Env.env -> + env -> decl tparam list -> - Env.env * (locl ty * Ast_defs.constraint_kind * locl ty) list + env * (locl ty * Ast_defs.constraint_kind * locl ty) list val localize_where_constraints: ety_env:expand_env -> - Env.env -> + env -> Aast.where_constraint list -> - Env.env + env val localize_with_dty_validator: - Env.env -> + env -> decl ty -> - (env -> decl ty -> unit) -> - Env.env * locl ty + (expand_env -> decl ty -> unit) -> + env * locl ty val sub_type_decl: - Env.env -> + env -> decl ty -> decl ty -> Errors.typing_error_callback -> unit val unify_decl: - Env.env -> + env -> decl ty -> decl ty -> Errors.typing_error_callback -> @@ -76,17 +73,17 @@ val unify_decl: val check_tparams_constraints: use_pos:Pos.t -> ety_env:expand_env -> - Env.env -> + env -> decl tparam list -> - Env.env + env val check_where_constraints: in_class:bool -> use_pos:Pos.t -> ety_env:expand_env -> definition_pos:Pos.t -> - Env.env -> + env -> decl where_constraint list -> - Env.env + env val decl: decl ty -> phase_ty diff --git a/hphp/hack/src/typing/typing_print.ml b/hphp/hack/src/typing/typing_print.ml index bb067042817..9a449fc1103 100644 --- a/hphp/hack/src/typing/typing_print.ml +++ b/hphp/hack/src/typing/typing_print.ml @@ -14,6 +14,7 @@ open Core_kernel open Typing_defs +open Typing_env_types open Typing_logic open Utils @@ -276,9 +277,9 @@ module Full = struct | Tdestructure tyl -> list "list(" k tyl ")" | Tanon (_, id) -> begin match Env.get_anonymous env id with - | Some { Env. rx = Reactive _; is_coroutine = true; _ } -> text "[coroutine rx fun]" - | Some { Env. rx = Nonreactive; is_coroutine = true; _ } -> text "[coroutine fun]" - | Some { Env. rx = Reactive _; is_coroutine = false; _ } -> text "[rx fun]" + | Some { rx = Reactive _; is_coroutine = true; _ } -> text "[coroutine rx fun]" + | Some { rx = Nonreactive; is_coroutine = true; _ } -> text "[coroutine fun]" + | Some { rx = Reactive _; is_coroutine = false; _ } -> text "[rx fun]" | _ -> text "[fun]" end | Tunion [] -> @@ -742,7 +743,7 @@ let string_to_param_mode = function | "inout" -> Some FPinout | _ -> None -let rec from_type: type a. Typing_env.env -> a ty -> json = +let rec from_type: type a. env -> a ty -> json = function env -> function ty -> (* Helpers to construct fields that appear in JSON rendering of type *) let kind k = ["kind", JSON_String k] in diff --git a/hphp/hack/src/typing/typing_print.mli b/hphp/hack/src/typing/typing_print.mli index 28a1031305c..e330153ca5d 100644 --- a/hphp/hack/src/typing/typing_print.mli +++ b/hphp/hack/src/typing/typing_print.mli @@ -7,35 +7,36 @@ * *) +open Typing_env_types (*****************************************************************************) (* Pretty printing of types *) (*****************************************************************************) -val error: Typing_env.env -> Typing_defs.locl Typing_defs.ty -> string +val error: env -> Typing_defs.locl Typing_defs.ty -> string val suggest: 'a Typing_defs.ty -> string -val full: Typing_env.env -> 'a Typing_defs.ty -> string -val full_rec: Typing_env.env -> int -> 'a Typing_defs.ty -> string -val full_strip_ns: Typing_env.env -> 'a Typing_defs.ty -> string +val full: env -> 'a Typing_defs.ty -> string +val full_rec: env -> int -> 'a Typing_defs.ty -> string +val full_strip_ns: env -> 'a Typing_defs.ty -> string val full_decl: TypecheckerOptions.t -> Typing_defs.decl Typing_defs.ty -> string val fun_type: TypecheckerOptions.t -> Typing_defs.decl Typing_defs.fun_type -> string (** Pretty print a type and all of its associated declaration information. *) val full_with_identity: - Typing_env.env -> + env -> 'a Typing_defs.ty -> 'b SymbolOccurrence.t -> 'b SymbolDefinition.t option -> string -val debug: Typing_env.env -> 'a Typing_defs.ty -> string +val debug: env -> 'a Typing_defs.ty -> string val with_blank_tyvars: (unit -> 'a) -> 'a val class_: TypecheckerOptions.t -> Decl_provider.class_decl -> string val gconst: TypecheckerOptions.t -> Decl_provider.gconst_decl -> string val fun_: TypecheckerOptions.t -> Decl_provider.fun_decl -> string val typedef: TypecheckerOptions.t -> Decl_provider.typedef_decl -> string -val constraints_for_type: Typing_env.env -> 'a Typing_defs.ty -> string option +val constraints_for_type: env -> 'a Typing_defs.ty -> string option val class_kind: Ast_defs.class_kind -> bool -> string -val subtype_prop: Typing_env.env -> Typing_logic.subtype_prop -> string +val subtype_prop: env -> Typing_logic.subtype_prop -> string (* Convert a type to a structured JSON value, as follows: * ::= "int" | "bool" | "float" | "string" | "num" | "arraykey" @@ -82,7 +83,7 @@ val subtype_prop: Typing_env.env -> Typing_logic.subtype_prop -> string * Expression-dependent type * { "kind":"expr" } *) -val to_json: Typing_env.env -> 'a Typing_defs.ty -> Hh_json.json +val to_json: env -> 'a Typing_defs.ty -> Hh_json.json (* Attempt to deserialize a previously-serialized type back into a type we can manipulate. Note that this function accesses the global state in diff --git a/hphp/hack/src/typing/typing_reactivity.ml b/hphp/hack/src/typing/typing_reactivity.ml index 01f7615e447..223ff9c9beb 100644 --- a/hphp/hack/src/typing/typing_reactivity.ml +++ b/hphp/hack/src/typing/typing_reactivity.ml @@ -9,6 +9,7 @@ open Core_kernel open Typing_defs +open Typing_env_types module Phase = Typing_phase module Env = Typing_env @@ -27,7 +28,7 @@ type method_call_info = { let make_call_info ~receiver_is_self ~is_static receiver_type method_name = { receiver_type; receiver_is_self; is_static; method_name; } -let type_to_str: type a. Env.env -> a ty -> string = fun env ty -> +let type_to_str: type a. env -> a ty -> string = fun env ty -> (* strip expression dependent types to make error message clearer *) let rec unwrap: type a. a ty -> a ty = function | _, Tabstract (AKdependent DTthis, Some ty) -> unwrap ty @@ -56,9 +57,9 @@ let get_associated_condition_type env ~is_self ty = | _, Tabstract (AKgeneric n, _) -> Env.get_condition_type env n | _, Tabstract (AKdependent DTthis, _) -> - condition_type_from_reactivity (Env.env_reactivity env) + condition_type_from_reactivity (env_reactivity env) | _ when is_self -> - condition_type_from_reactivity (Env.env_reactivity env) + condition_type_from_reactivity (env_reactivity env) | _ -> None (* removes condition type from given reactivity flavor *) @@ -188,7 +189,7 @@ let check_call env method_info pos reason ft arg_types = (* do nothing if unsafe_rx is set *) if TypecheckerOptions.unsafe_rx (Env.get_tcopt env) then () else - match Env.env_reactivity env with + match env_reactivity env with (* non reactive and locally reactive functions can call pretty much anything - do nothing *) | Nonreactive | Local _ -> () @@ -207,7 +208,7 @@ let check_call env method_info pos reason ft arg_types = | MaybeReactive (Local (Some _)) -> MaybeReactive (Local None) | MaybeReactive (RxVar (Some v)) -> MaybeReactive (RxVar (Some (go v))) | r -> r in - go (Env.env_reactivity env) in + go (env_reactivity env) in (* check that all conditions are met if we are calling something conditionally reactive *) let callee_is_conditionally_reactive = @@ -353,7 +354,7 @@ let try_substitute_type_with_condition env cond_ty ty = and it is not assignable to fresh type parameter. To handle this for returns we reduce return type to its upper bound if return type is TFresh and current context is non-reactive *) let strip_condition_type_in_return env ty = - if Env.env_reactivity env <> Nonreactive then ty + if env_reactivity env <> Nonreactive then ty else begin match ty with | _, Tabstract ((AKgeneric n), _) when Option.is_some (Env.get_condition_type env n) -> diff --git a/hphp/hack/src/typing/typing_requirements.mli b/hphp/hack/src/typing/typing_requirements.mli index 3746a9f9fb2..abf5508cfaf 100644 --- a/hphp/hack/src/typing/typing_requirements.mli +++ b/hphp/hack/src/typing/typing_requirements.mli @@ -7,4 +7,4 @@ * *) -val check_class : Typing_env.env -> Decl_provider.class_decl -> unit +val check_class : Typing_env_types.env -> Decl_provider.class_decl -> unit diff --git a/hphp/hack/src/typing/typing_return.mli b/hphp/hack/src/typing/typing_return.mli index 0fdd23c628e..19a505361ad 100644 --- a/hphp/hack/src/typing/typing_return.mli +++ b/hphp/hack/src/typing/typing_return.mli @@ -7,20 +7,20 @@ * *) -module Env = Typing_env +open Typing_env_types (** Typing code concerned with return types. *) val make_info: Ast_defs.fun_kind -> Nast.user_attribute list -> - Env.env -> + env -> is_explicit:bool -> Typing_defs.locl Typing_defs.ty -> Typing_defs.decl Typing_defs.ty option -> Typing_env_return_info.t val suggest_return: - Env.env -> + env -> Ast_defs.pos -> Typing_defs.locl Typing_defs.ty -> (int -> bool) -> unit @@ -31,33 +31,33 @@ val async_suggest_return: Ast_defs.pos -> unit val implicit_return: - Env.env -> + env -> Ast_defs.pos -> expected:Typing_defs.locl Typing_defs.ty -> - actual:Typing_defs.locl Typing_defs.ty -> Env.env + actual:Typing_defs.locl Typing_defs.ty -> env (** For async functions, wrap Awaitable<_> around the return type *) val wrap_awaitable: - Env.env -> + env -> Ast_defs.pos -> Typing_defs.locl Typing_defs.ty -> Typing_defs.locl Typing_defs.ty val make_return_type: - (Env.env -> Typing_defs.decl Typing_defs.ty -> Env.env * Typing_defs.locl Typing_defs.ty) -> - Env.env -> - Typing_defs.decl Typing_defs.ty -> Env.env * Typing_defs.locl Typing_defs.ty + (env -> Typing_defs.decl Typing_defs.ty -> env * Typing_defs.locl Typing_defs.ty) -> + env -> + Typing_defs.decl Typing_defs.ty -> env * Typing_defs.locl Typing_defs.ty (** For async functions, strip Awaitable<_> from the return type *) val strip_awaitable: Ast_defs.fun_kind -> - Env.env -> + env -> Typing_defs.locl Typing_defs.possibly_enforced_ty -> Typing_defs.locl Typing_defs.possibly_enforced_ty val force_awaitable: - Env.env -> + env -> Ast_defs.pos -> Typing_defs.locl Typing_defs.ty -> - Env.env * Typing_defs.locl Typing_defs.ty + env * Typing_defs.locl Typing_defs.ty (** If there is no return type annotation on method, assume `void` for the special functions `__construct`, otherwise we can either @@ -65,5 +65,5 @@ introduce a new fresh variable when infer missing is on or assume type Tany *) val make_default_return: is_method:bool -> is_infer_missing_on:bool -> - Env.env -> - Ast_defs.pos * string -> Env.env * (Typing_reason.t * Typing_defs.locl Typing_defs.ty_) + env -> + Ast_defs.pos * string -> env * (Typing_reason.t * Typing_defs.locl Typing_defs.ty_) diff --git a/hphp/hack/src/typing/typing_solver.ml b/hphp/hack/src/typing/typing_solver.ml index 06b333d2391..51eb498b1ca 100644 --- a/hphp/hack/src/typing/typing_solver.ml +++ b/hphp/hack/src/typing/typing_solver.ml @@ -10,6 +10,7 @@ open Core_kernel open Common open Typing_defs +open Typing_env_types module Reason = Typing_reason module Env = Typing_env @@ -142,7 +143,7 @@ and freshen_tparams env variancel tyl = let var_occurs_in_ty env var ty = let finder = object - inherit [Env.env * bool] Type_visitor.type_visitor + inherit [env * bool] Type_visitor.type_visitor method! on_tvar (env, occurs) _r v = if occurs then env, occurs else let env, v = Env.get_var env v in @@ -404,8 +405,8 @@ let try_bind_to_equal_bound ~freshen env r var on_error = let expand_all tyset = Typing_set.map (fun ty -> let _, ty = Env.expand_type env ty in ty) tyset in let tyvar_info = Env.get_tyvar_info env var in - let lower_bounds = expand_all tyvar_info.Env.lower_bounds in - let upper_bounds = expand_all tyvar_info.Env.upper_bounds in + let lower_bounds = expand_all tyvar_info.lower_bounds in + let upper_bounds = expand_all tyvar_info.upper_bounds in let equal_bounds = Typing_set.inter lower_bounds upper_bounds in let r = Reason.none in let any = (r, Typing_defs.make_tany ()) and err = (r, Terr) in let equal_bounds = equal_bounds |> TySet.remove any |> TySet.remove err in @@ -445,8 +446,8 @@ let rec always_solve_tyvar ~freshen env r var on_error = then env else let tyvar_info = Env.get_tyvar_info env var in - let r = if r = Reason.Rnone then Reason.Rwitness tyvar_info.Env.tyvar_pos else r in - let env = bind_to_lower_bound ~freshen env r var tyvar_info.Env.lower_bounds on_error in + let r = if r = Reason.Rnone then Reason.Rwitness tyvar_info.tyvar_pos else r in + let env = bind_to_lower_bound ~freshen env r var tyvar_info.lower_bounds on_error in let env, ety = Env.expand_var env r var in match ety with | _, Tvar var' when var <> var' -> always_solve_tyvar ~freshen env r var on_error @@ -478,9 +479,9 @@ let solve_tyvar_wrt_variance env r var on_error = then env else let tyvar_info = Env.get_tyvar_info env var in - let r = if r = Reason.Rnone then Reason.Rwitness tyvar_info.Env.tyvar_pos else r in - let lower_bounds = tyvar_info.Env.lower_bounds and upper_bounds = tyvar_info.Env.upper_bounds in - match tyvar_info.Env.appears_covariantly, tyvar_info.Env.appears_contravariantly with + let r = if r = Reason.Rnone then Reason.Rwitness tyvar_info.tyvar_pos else r in + let lower_bounds = tyvar_info.lower_bounds and upper_bounds = tyvar_info.upper_bounds in + match tyvar_info.appears_covariantly, tyvar_info.appears_contravariantly with | true, false | false, false -> (* As in Local Type Inference by Pierce & Turner, if type variable does @@ -511,7 +512,7 @@ let solve_all_unsolved_tyvars env on_error = Env.log_env_change "solve_all_unsolved_tyvars" env @@ IMap.fold (fun tyvar _ env -> - always_solve_tyvar ~freshen:false env Reason.Rnone tyvar on_error) env.Env.tvenv env in + always_solve_tyvar ~freshen:false env Reason.Rnone tyvar on_error) env.tvenv env in Typing_subtype.log_prop env; env diff --git a/hphp/hack/src/typing/typing_solver.mli b/hphp/hack/src/typing/typing_solver.mli index ffd20bc60bd..ea524728eab 100644 --- a/hphp/hack/src/typing/typing_solver.mli +++ b/hphp/hack/src/typing/typing_solver.mli @@ -1,54 +1,55 @@ module Env = Typing_env open Typing_defs +open Typing_env_types (** Non-side-effecting test for subtypes. result = true implies ty1 <: ty2 result = false implies NOT ty1 <: ty2 OR we don't know *) val is_sub_type : - Env.env -> + env -> locl ty -> locl ty -> bool val push_option_out : Pos.t -> - Env.env -> + env -> locl ty -> - Env.env * locl ty + env * locl ty val non_null : - Env.env -> + env -> Pos.t -> locl ty -> - Env.env * locl ty + env * locl ty (* Force solve all remaining unsolved type variables *) val solve_all_unsolved_tyvars : - Env.env -> + env -> Errors.typing_error_callback -> - Env.env + env val expand_type_and_solve : - Env.env -> + env -> description_of_expected:string -> Pos.t -> locl ty -> Errors.typing_error_callback -> - Env.env * locl ty + env * locl ty val expand_type_and_narrow : - Env.env -> + env -> ?default:locl ty -> description_of_expected:string -> - (Env.env -> locl ty -> Env.env * locl ty option) -> + (env -> locl ty -> env * locl ty option) -> Pos.t -> locl ty -> Errors.typing_error_callback -> - Env.env * locl ty + env * locl ty val close_tyvars_and_solve : - Env.env -> + env -> Errors.typing_error_callback -> - Env.env + env diff --git a/hphp/hack/src/typing/typing_substring.ml b/hphp/hack/src/typing/typing_substring.ml index af6e35562f2..85b6790f947 100644 --- a/hphp/hack/src/typing/typing_substring.ml +++ b/hphp/hack/src/typing/typing_substring.ml @@ -9,6 +9,7 @@ open Core_kernel open Typing_defs +open Typing_env_types module Reason = Typing_reason module Env = Typing_env @@ -20,8 +21,8 @@ let is_object env ty = let sub_string (p : Pos.Map.key) - (env : Env.env) - (ty : locl ty) : Env.env = + (env : env) + (ty : locl ty) : env = (* Under constraint-based inference, we implement sub_string as a subtype test. * All the cases in the legacy implementation just fall out from subtyping rules. * We test against ?(arraykey | bool | float | resource | object | dynamic | diff --git a/hphp/hack/src/typing/typing_subtype.ml b/hphp/hack/src/typing/typing_subtype.ml index eb98583c8ca..44642849475 100644 --- a/hphp/hack/src/typing/typing_subtype.ml +++ b/hphp/hack/src/typing/typing_subtype.ml @@ -11,6 +11,7 @@ open Core_kernel open Common open Utils open Typing_defs +open Typing_env_types module Reason = Typing_reason module Unify = Typing_unify @@ -42,7 +43,7 @@ let empty_extra_info = { } module ConditionTypes = struct - let try_get_class_for_condition_type (env: Env.env) (ty: decl ty) = + let try_get_class_for_condition_type (env: env) (ty: decl ty) = match TUtils.try_unwrap_class_type ty with | None -> None | Some (_, ((_, x) as sid), _) -> @@ -52,7 +53,7 @@ module ConditionTypes = struct end let try_get_method_from_condition_type - (env: Env.env) + (env: env) (ty: decl ty) (is_static: bool) (method_name: string) = @@ -63,7 +64,7 @@ module ConditionTypes = struct | None -> None - let localize_condition_type (env: Env.env) (ty: decl ty): locl ty = + let localize_condition_type (env: env) (ty: decl ty): locl ty = (* if condition type is generic - we cannot specify type argument in attribute. For cases when we check if containing type is a subtype of condition type if condition type is generic instantiate it with TAny's *) @@ -117,23 +118,23 @@ end * If assertion is unsatisfiable (e.g. arraykey <: string) then * we record this in the failed field of the result. *) -let with_error (f : unit -> unit) ((env, p) : (Env.env * TL.subtype_prop)) - : Env.env * TL.subtype_prop = +let with_error (f : unit -> unit) ((env, p) : (env * TL.subtype_prop)) + : env * TL.subtype_prop = env, TL.conj p (TL.invalid ~fail:f) (* If `b` is false then fail with error function `f` *) let check_with b f r = if not b then with_error f r else r -let valid env : Env.env * TL.subtype_prop = env, TL.valid +let valid env : env * TL.subtype_prop = env, TL.valid -let (&&&) (env, p1) (f : Env.env -> Env.env * TL.subtype_prop) = +let (&&&) (env, p1) (f : env -> env * TL.subtype_prop) = if TL.is_unsat p1 then env, p1 else let env, p2 = f env in env, TL.conj p1 p2 -let if_unsat (f : unit -> Env.env * TL.subtype_prop) (env, p) = +let if_unsat (f : unit -> env * TL.subtype_prop) (env, p) = if TL.is_unsat p then f () else env, p @@ -261,7 +262,7 @@ and simplify_subtype (ty_sub : locl ty) (ty_super : locl ty) ~(on_error : Errors.typing_error_callback) - env : Env.env * TL.subtype_prop = + env : env * TL.subtype_prop = log_subtype ~level:2 ~this_ty ~function_name:"simplify_subtype" env ty_sub ty_super; let env, ety_super = Env.expand_type env ty_super in let env, ety_sub = Env.expand_type env ty_sub in @@ -273,7 +274,7 @@ and simplify_subtype (fst ety_sub) (snd ety_sub) on_error in - let (|||) (env, p1) (f : Env.env -> Env.env * TL.subtype_prop) = + let (|||) (env, p1) (f : env -> env * TL.subtype_prop) = if TL.is_valid p1 then env, p1 else @@ -512,7 +513,7 @@ and simplify_subtype begin match Env.get_anonymous env id with | None -> invalid_with (fun () -> Errors.anonymous_recursive_call (Reason.to_pos r_sub)) - | Some { Env. rx = reactivity; is_coroutine; counter = ftys; typecheck = anon; _ } -> + | Some { rx = reactivity; is_coroutine; counter = ftys; typecheck = anon; _ } -> let p_super = Reason.to_pos r_super in let p_sub = Reason.to_pos r_sub in (* Add function type to set of types seen so far *) @@ -1262,7 +1263,7 @@ and simplify_subtype_variance (children_tyl : locl ty list) (super_tyl : locl ty list) ~(on_error : Errors.typing_error_callback) - : Env.env -> Env.env * TL.subtype_prop + : env -> env * TL.subtype_prop = fun env -> let simplify_subtype = simplify_subtype ~no_top_bottom ~seen_generic_params ~on_error ~this_ty:None in @@ -1416,7 +1417,7 @@ and simplify_supertype_params_with_variadic and subtype_reactivity ?(extra_info: reactivity_extra_info option) ?(is_call_site = false) - (env : Env.env) + (env : env) (r_sub : reactivity) (r_super : reactivity) : bool = @@ -1536,7 +1537,7 @@ and should_check_fun_params_reactivity (* checks condition described by OnlyRxIfImpl condition on parameter is met *) and subtype_param_rx_if_impl ~is_param - (env: Env.env) + (env: env) (cond_type_sub: decl ty option) (declared_type_sub: locl ty option) (cond_type_super: decl ty option) = @@ -1810,7 +1811,7 @@ and simplify_subtype_possibly_enforced (ft_super : locl fun_type) (on_error : Errors.typing_error_callback) env - : Env.env * TL.subtype_prop = + : env * TL.subtype_prop = let variadic_subtype = match ft_sub.ft_arity with | Fvariadic (_, {fp_type = var_sub; _ }) -> Some var_sub | _ -> None in @@ -1854,11 +1855,11 @@ and simplify_subtype_possibly_enforced (* One of the main entry points to this module *) and sub_type - (env : Env.env) + (env : env) (ty_sub : locl ty) (ty_super : locl ty) (on_error : Errors.typing_error_callback) - : Env.env = + : env = Env.log_env_change "sub_type" env @@ sub_type_inner env ~this_ty:None ty_sub ty_super on_error @@ -1947,11 +1948,11 @@ and prop_to_env env prop on_error = env, TL.conj_list props' and env_to_prop env = - TL.conj (tvenv_to_prop env.Env.tvenv) env.Env.subtype_prop + TL.conj (tvenv_to_prop env.tvenv) env.subtype_prop and tvenv_to_prop tvenv = let props_per_tvar = IMap.mapi ( - fun id { Env.lower_bounds; Env.upper_bounds; _ } -> + fun id { lower_bounds; upper_bounds; _ } -> let tyvar = (Reason.Rnone, Tvar id) in let lower_bounds = TySet.elements lower_bounds in let upper_bounds = TySet.elements upper_bounds in @@ -1977,12 +1978,12 @@ and tvenv_to_prop tvenv = TL.conj_list props and sub_type_inner - (env : Env.env) + (env : env) ~(this_ty : locl ty option) (ty_sub: locl ty) (ty_super: locl ty) (on_error : Errors.typing_error_callback) - : Env.env = + : env = log_subtype ~level:1 ~this_ty ~function_name:"sub_type_inner" env ty_sub ty_super; let env, prop = simplify_subtype ~seen_generic_params:empty_seen @@ -2001,7 +2002,7 @@ and sub_type_inner * before calling sub_type and then re-enable it afterwards. *) and is_sub_type_LEGACY_DEPRECATED - (env : Env.env) + (env : env) (ty_sub : locl ty) (ty_super : locl ty) : bool = (* quick short circuit to help perf *) @@ -2147,12 +2148,12 @@ and try_union env ty tyl = let subtype_method ~(check_return : bool) ~(extra_info: reactivity_extra_info) - (env : Env.env) + (env : env) (r_sub : Reason.t) (ft_sub : decl fun_type) (r_super : Reason.t) (ft_super : decl fun_type) - (on_error : Errors.typing_error_callback) : Env.env = + (on_error : Errors.typing_error_callback) : env = if not ft_super.ft_abstract && ft_sub.ft_abstract then (* It is valid for abstract class to extend a concrete class, but it cannot * redefine already concrete members as abstract. @@ -2227,10 +2228,10 @@ let subtype_method Env.env_with_tpenv env old_tpenv let decompose_subtype_add_bound - (env : Env.env) + (env : env) (ty_sub : locl ty) (ty_super : locl ty) - : Env.env = + : env = let env, ty_super = Env.expand_type env ty_super in let env, ty_sub = Env.expand_type env ty_sub in match ty_sub, ty_super with @@ -2276,11 +2277,11 @@ let decompose_subtype_add_bound *) let rec decompose_subtype p - (env : Env.env) + (env : env) (ty_sub : locl ty) (ty_super : locl ty) (on_error : Errors.typing_error_callback) - : Env.env = + : env = log_subtype ~level:2 ~this_ty:None ~function_name:"decompose_subtype" env ty_sub ty_super; let env, prop = simplify_subtype ~seen_generic_params:None @@ -2294,7 +2295,7 @@ and decompose_subtype_add_prop p env prop = | TL.Disj (_, [prop']) -> decompose_subtype_add_prop p env prop' | TL.Disj _ -> - Typing_log.log_prop 2 env.Env.function_pos "decompose_subtype_add_prop" env prop; + Typing_log.log_prop 2 env.function_pos "decompose_subtype_add_prop" env prop; env | TL.IsSubtype (ty1, ty2) -> decompose_subtype_add_bound env ty1 ty2 @@ -2302,11 +2303,11 @@ and decompose_subtype_add_prop p env prop = (* Decompose a general constraint *) and decompose_constraint p - (env : Env.env) + (env : env) (ck : Ast_defs.constraint_kind) (ty_sub : locl ty) (ty_super : locl ty) - : Env.env = + : env = (* constraints are caught based on reason, not error callback. Using unify_error *) match ck with | Ast_defs.Constraint_as -> @@ -2340,10 +2341,10 @@ and decompose_constraint let constraint_iteration_limit = 20 let add_constraint p - (env : Env.env) + (env : env) (ck : Ast_defs.constraint_kind) (ty_sub : locl ty) - (ty_super : locl ty) : Env.env = + (ty_super : locl ty) : env = log_subtype ~level:1 ~this_ty:None ~function_name:"add_constraint" env ty_sub ty_super; let oldsize = Env.get_tpenv_size env in let env' = decompose_constraint p env ck ty_sub ty_super in @@ -2369,19 +2370,19 @@ let add_constraint iter 0 env' let log_prop env = - let filename = Pos.filename (Pos.to_absolute env.Env.function_pos) in + let filename = Pos.filename (Pos.to_absolute env.function_pos) in if Str.string_match (Str.regexp {|.*\.hhi|}) filename 0 then () else let prop = env_to_prop env in if TypecheckerOptions.log_inference_constraints (Env.get_tcopt env) then ( let p_as_string = Typing_print.subtype_prop env prop in - let pos = Pos.string (Pos.to_absolute env.Env.function_pos) in + let pos = Pos.string (Pos.to_absolute env.function_pos) in let size = TL.size prop in let n_disj = TL.n_disj prop in let n_conj = TL.n_conj prop in TypingLogger.InferenceCnstr.log p_as_string ~pos ~size ~n_disj ~n_conj); if not (Errors.currently_has_errors ()) && not (TL.is_valid prop) - then Typing_log.log_prop 1 env.Env.function_pos + then Typing_log.log_prop 1 env.function_pos "There are remaining unsolved constraints!" env prop (*****************************************************************************) diff --git a/hphp/hack/src/typing/typing_subtype.mli b/hphp/hack/src/typing/typing_subtype.mli index 4ec16dd91aa..0734585ecd8 100644 --- a/hphp/hack/src/typing/typing_subtype.mli +++ b/hphp/hack/src/typing/typing_subtype.mli @@ -1,6 +1,7 @@ module Env = Typing_env open Typing_defs +open Typing_env_types type reactivity_extra_info = { method_info: ((* method_name *) string * (* is_static *) bool) option; @@ -10,25 +11,25 @@ type reactivity_extra_info = { module ConditionTypes : sig val try_get_class_for_condition_type : - Env.env -> + env -> decl ty -> ((Ast_defs.pos * string) * Decl_provider.class_decl) option val try_get_method_from_condition_type : - Env.env -> + env -> decl ty -> bool -> string -> class_elt option val localize_condition_type : - Env.env -> + env -> decl ty -> locl ty end val is_sub_type_LEGACY_DEPRECATED : - Env.env -> + env -> locl ty -> locl ty -> bool @@ -38,25 +39,25 @@ val is_sub_type_LEGACY_DEPRECATED : result = false implies NOT ty1 <: ty2 OR we don't know *) val is_sub_type : - Env.env -> + env -> locl ty -> locl ty -> bool val is_sub_type_ignore_generic_params : - Env.env -> + env -> locl ty -> locl ty -> bool val is_sub_type_for_union : - Env.env -> + env -> locl ty -> locl ty -> bool val can_sub_type : - Env.env -> + env -> locl ty -> locl ty -> bool @@ -70,41 +71,41 @@ val can_sub_type : sub_type env int string => error *) val sub_type : - Env.env -> + env -> locl ty -> locl ty -> Errors.typing_error_callback -> - Env.env + env (** Check that the method with signature ft_sub can be used to override (is a subtype of) method with signature ft_super. *) val subtype_method : check_return:bool -> extra_info:reactivity_extra_info -> - Env.env -> + env -> Reason.t -> decl fun_type -> Reason.t -> decl fun_type -> Errors.typing_error_callback -> - Env.env + env val subtype_reactivity : ?extra_info:reactivity_extra_info -> ?is_call_site:bool -> - Env.env -> + env -> reactivity -> reactivity -> bool val add_constraint : Pos.t -> - Env.env -> + env -> Ast_defs.constraint_kind -> locl ty -> locl ty -> - Env.env + env val log_prop : - Env.env -> + env -> unit diff --git a/hphp/hack/src/typing/typing_subtype_tconst.mli b/hphp/hack/src/typing/typing_subtype_tconst.mli index 21bd0d48abf..aa0259563e7 100644 --- a/hphp/hack/src/typing/typing_subtype_tconst.mli +++ b/hphp/hack/src/typing/typing_subtype_tconst.mli @@ -1,14 +1,15 @@ open Typing_defs +open Typing_env_types module Env = Typing_env (** For all type constant T of type variable, make its type equal to `ty`::T *) val make_all_type_consts_equal: - Env.env -> + env -> Ident.t -> locl ty -> as_tyvar_with_cnstr:bool -> - Env.env + env (** Get the type of a type constant of a type variable by looking it up in the environment. @@ -16,7 +17,7 @@ If that type constant is not present, make a fresh invariant type variable and add it as the type of the type constant in the environment. *) val get_tyvar_type_const: - Env.env -> + env -> Ident.t -> Aast.sid -> - Env.env * locl ty + env * locl ty diff --git a/hphp/hack/src/typing/typing_taccess.ml b/hphp/hack/src/typing/typing_taccess.ml index 9342c57b1f3..8eca5570f1a 100644 --- a/hphp/hack/src/typing/typing_taccess.ml +++ b/hphp/hack/src/typing/typing_taccess.ml @@ -26,8 +26,8 @@ exception NoTypeConst of (unit -> unit) let raise_error error = raise_notrace @@ NoTypeConst error type env = { - tenv : Env.env; - ety_env : Phase.env; + tenv : Typing_env_types.env; + ety_env : expand_env; choose_assigned_type : bool; (* A list of generics we've seen while expanding. *) gen_seen : TySet.t; @@ -70,7 +70,7 @@ and expand_with_env_ ety_env env ~as_tyvar_with_cnstr root id = (* if type constant has type this::ID and method has associated condition type ROOTCOND_TY for the receiver - check if condition type has type constant at the same path. If yes - attach a condition type ROOTCOND_TY::ID to a result type *) - begin match root, id, TR.condition_type_from_reactivity (Env.env_reactivity tenv) with + begin match root, id, TR.condition_type_from_reactivity (Typing_env_types.env_reactivity tenv) with | (_, Tabstract (AKdependent (DTthis), _)), (_, tconst), Some cond_ty -> diff --git a/hphp/hack/src/typing/typing_taccess.mli b/hphp/hack/src/typing/typing_taccess.mli index 59f12255680..7fe1f3bab33 100644 --- a/hphp/hack/src/typing/typing_taccess.mli +++ b/hphp/hack/src/typing/typing_taccess.mli @@ -8,11 +8,12 @@ *) open Typing_defs +open Typing_env_types (* Returns (class_name, tconst_name, tconst_reference_position) for each type * constant referenced in a type access. *) val referenced_typeconsts: - Typing_env.env -> + env -> expand_env -> taccess_type -> (string * string * Pos.t) list diff --git a/hphp/hack/src/typing/typing_union.mli b/hphp/hack/src/typing/typing_union.mli index b7612e38e0a..ad71bbecb60 100644 --- a/hphp/hack/src/typing/typing_union.mli +++ b/hphp/hack/src/typing/typing_union.mli @@ -8,6 +8,7 @@ *) open Typing_defs +open Typing_env_types module Env = Typing_env @@ -21,18 +22,18 @@ then This approximation is necessary to avoid type growing exponentially in size. We have seen cases where it would otherwise generate unions involving all the subsets of a set of types. *) -val union: Env.env -> locl ty -> locl ty -> Env.env * locl ty +val union: env -> locl ty -> locl ty -> env * locl ty (** Computes the union of a list of types by union types two by two. This is quadratic, so if this requires more than 20 two by two unions, fall back to simply flatten the unions, bubble up the option and remove duplicates. *) -val union_list: Env.env -> Reason.t -> locl ty list -> Env.env * locl ty +val union_list: env -> Reason.t -> locl ty list -> env * locl ty (** Simplify unions in a type. *) val simplify_unions: - Env.env -> - ?on_tyvar:(Env.env -> Reason.t -> Ident.t -> Env.env * locl ty) -> + env -> + ?on_tyvar:(env -> Reason.t -> Ident.t -> env * locl ty) -> locl ty -> - Env.env * locl ty + env * locl ty (** A cheap type difference. If ty1 is a union, remove ty2 from this union. Assumes ty1 is a flattened union or an option of a flattened union, and ty2 is a type variable *) diff --git a/hphp/hack/src/typing/typing_utils.ml b/hphp/hack/src/typing/typing_utils.ml index 4fde923e12e..636244d7cdc 100644 --- a/hphp/hack/src/typing/typing_utils.ml +++ b/hphp/hack/src/typing/typing_utils.ml @@ -10,6 +10,7 @@ open Core_kernel open Common open Typing_defs +open Typing_env_types module Nast = Aast module SN = Naming_special_names @@ -38,47 +39,47 @@ let ty_size env ty = (*****************************************************************************) let not_implemented s _ = failwith (Printf.sprintf "Function %s not implemented" s) type expand_typedef = - expand_env -> Env.env -> Reason.t -> string -> locl ty list -> Env.env * locl ty + expand_env -> env -> Reason.t -> string -> locl ty list -> env * locl ty let (expand_typedef_ref : expand_typedef ref) = ref (not_implemented "expand_typedef") let expand_typedef x = !expand_typedef_ref x -type sub_type = Env.env -> locl ty -> locl ty -> Errors.typing_error_callback -> Env.env +type sub_type = env -> locl ty -> locl ty -> Errors.typing_error_callback -> env let (sub_type_ref: sub_type ref) = ref (not_implemented "sub_type") let sub_type x = !sub_type_ref x type is_sub_type_type = - Env.env -> locl ty -> locl ty -> bool + env -> locl ty -> locl ty -> bool (*let (is_sub_type_ref: is_sub_type_type ref) = ref not_implemented*) let (is_sub_type_for_union_ref: is_sub_type_type ref) = ref (not_implemented "is_sub_type_for_union") let is_sub_type_for_union x = !is_sub_type_for_union_ref x -type add_constraint = Pos.Map.key -> Env.env -> Ast_defs.constraint_kind -> locl ty -> locl ty -> Env.env +type add_constraint = Pos.Map.key -> env -> Ast_defs.constraint_kind -> locl ty -> locl ty -> env let (add_constraint_ref: add_constraint ref) = ref (not_implemented "add_constraint") let add_constraint x = !add_constraint_ref x type expand_typeconst = - expand_env -> Env.env -> ?as_tyvar_with_cnstr:bool -> locl ty -> - Aast.sid -> Env.env * locl ty + expand_env -> env -> ?as_tyvar_with_cnstr:bool -> locl ty -> + Aast.sid -> env * locl ty let (expand_typeconst_ref: expand_typeconst ref) = ref (not_implemented "expand_typeconst") let expand_typeconst x = !expand_typeconst_ref x -type union = Env.env -> locl ty -> locl ty -> Env.env * locl ty +type union = env -> locl ty -> locl ty -> env * locl ty let (union_ref: union ref) = ref (not_implemented "union") let union x = !union_ref x -type union_list = Env.env -> Reason.t -> locl ty list -> (Env.env * locl ty) +type union_list = env -> Reason.t -> locl ty list -> (env * locl ty) let (union_list_ref : union_list ref) = ref (not_implemented "union_list") let union_list x = !union_list_ref x -type fold_union = Env.env -> Reason.t -> locl ty list -> Env.env * locl ty +type fold_union = env -> Reason.t -> locl ty list -> env * locl ty let (fold_union_ref : fold_union ref) = ref (not_implemented "fold_union") let fold_union x = !fold_union_ref x type simplify_unions = - Env.env -> - ?on_tyvar:(Env.env -> Reason.t -> Ident.t -> Env.env * locl ty) -> + env -> + ?on_tyvar:(env -> Reason.t -> Ident.t -> env * locl ty) -> locl ty -> - Env.env * locl ty + env * locl ty let (simplify_unions_ref : simplify_unions ref) = ref (not_implemented "simplify_unions") let simplify_unions x = !simplify_unions_ref x @@ -87,31 +88,31 @@ let (diff_ref : diff ref) = ref (not_implemented "diff") let diff x = !diff_ref x type approx = ApproxUp | ApproxDown -type non = Env.env -> Reason.t -> locl ty -> approx:approx -> (Env.env * locl ty) +type non = env -> Reason.t -> locl ty -> approx:approx -> (env * locl ty) let (non_ref : non ref) = ref (not_implemented "non") let non x = !non_ref x -type simplify_intersections = Env.env -> - ?on_tyvar:(Env.env -> Reason.t -> int -> Env.env * locl ty) -> locl ty -> Env.env * locl ty +type simplify_intersections = env -> + ?on_tyvar:(env -> Reason.t -> int -> env * locl ty) -> locl ty -> env * locl ty let (simplify_intersections_ref : simplify_intersections ref) = ref (not_implemented "simplify_intersections") let simplify_intersections x = !simplify_intersections_ref x -type localize_with_self = Env.env -> decl ty -> Env.env * locl ty +type localize_with_self = env -> decl ty -> env * locl ty let (localize_with_self_ref : localize_with_self ref) = ref (not_implemented "localize_with_self") let localize_with_self x = !localize_with_self_ref x type coerce_type = Pos.t -> - ?sub_fn:(Pos.t -> Reason.ureason -> Env.env -> locl ty -> locl ty -> - Errors.typing_error_callback -> Env.env) -> - Reason.ureason -> Env.env -> locl ty -> locl possibly_enforced_ty -> - Errors.typing_error_callback -> Env.env + ?sub_fn:(Pos.t -> Reason.ureason -> env -> locl ty -> locl ty -> + Errors.typing_error_callback -> env) -> + Reason.ureason -> env -> locl ty -> locl possibly_enforced_ty -> + Errors.typing_error_callback -> env let (coerce_type_ref : coerce_type ref) = ref (not_implemented "coerce_type") let coerce_type x = !coerce_type_ref x -type can_coerce = Pos.t -> Env.env -> ?ur:Reason.ureason -> locl ty -> +type can_coerce = Pos.t -> env -> ?ur:Reason.ureason -> locl ty -> locl possibly_enforced_ty -> - Errors.typing_error_callback -> Env.env option + Errors.typing_error_callback -> env option let (can_coerce_ref : can_coerce ref) = ref (not_implemented "can_coerce") let can_coerce x = !can_coerce_ref x diff --git a/hphp/hack/src/typing/typing_visibility.mli b/hphp/hack/src/typing/typing_visibility.mli index 7303d8be06f..81082935fa3 100644 --- a/hphp/hack/src/typing/typing_visibility.mli +++ b/hphp/hack/src/typing/typing_visibility.mli @@ -8,19 +8,20 @@ **) open Typing_defs +open Typing_env_types val check_class_access: - Pos.t -> Typing_env.env -> (Pos.t * visibility * bool) -> Nast.class_id_ -> + Pos.t -> env -> (Pos.t * visibility * bool) -> Nast.class_id_ -> Decl_provider.class_decl -> unit val check_obj_access: - Pos.t -> Typing_env.env -> (Pos.t * visibility) -> unit + Pos.t -> env -> (Pos.t * visibility) -> unit val check_inst_meth_access: Pos.t -> (Pos.t * visibility) -> unit val is_visible: - Typing_env.env -> (visibility * bool) -> Nast.class_id_ option -> Decl_provider.class_decl -> bool + env -> (visibility * bool) -> Nast.class_id_ option -> Decl_provider.class_decl -> bool val min_vis_opt: (Pos.t * visibility) option -> (Pos.t * visibility) option -> diff --git a/hphp/hack/src/typing/typing_xhp.mli b/hphp/hack/src/typing/typing_xhp.mli index 3221616bba0..fe7a1ecab16 100644 --- a/hphp/hack/src/typing/typing_xhp.mli +++ b/hphp/hack/src/typing/typing_xhp.mli @@ -7,6 +7,8 @@ * *) +open Typing_env_types + (** * This is used in computing all possible attributes for XHP spreads. * @@ -15,17 +17,17 @@ * XHP onto which we are spreading. *) val get_spread_attributes : - Typing_env.env -> + env -> Pos.t -> Decl_provider.class_decl -> Typing_defs.locl Typing_defs.ty -> - Typing_env.env * (Aast.pstring * (Pos.t * Typing_defs.locl Typing_defs.ty)) list + env * (Aast.pstring * (Pos.t * Typing_defs.locl Typing_defs.ty)) list (** * Verify that an XHP body expression is legal. *) val is_xhp_child : - Typing_env.env -> + env -> Pos.t -> Typing_defs.locl Typing_defs.ty -> bool -- 2.11.4.GIT