Enforce Pos_or_decl.t in reasons for decl types
commita55e4eaafaa6d9ae4a3e31fb410760f7760b4f39
authorCatherine Gasnier <catg@fb.com>
Mon, 8 Mar 2021 17:14:50 +0000 (8 09:14 -0800)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Mon, 8 Mar 2021 17:17:33 +0000 (8 09:17 -0800)
tree14d933e5abe71964ac01fd8539636f83f3d1a2a1
parentedd48de1dc4869c3b4e1da5bf0f76530868fa5cc
Enforce Pos_or_decl.t in reasons for decl types

Summary:
This is done by making Typing_reason.t a GADT with a phase type parameter, just like Typing_defs.ty, then redefining `ty` as:
```
<<<<<
type 'ph ty = Reason.t * 'ph ty_
=====
type 'ph ty = 'ph Reason.t * 'ph ty_
>>>>>
```
Reasons with a Pos.t are now `locl Typing_reason.t` while other reasons are just `'phase Typing_reason.t`.
This forbids `decl ty` to use a `locl Reason.t`, while `locl ty` is free to use any reason.

The rest of the changes is just to make the compiler happy.

Reviewed By: ljw1004

Differential Revision: D26516301

fbshipit-source-id: 19a6956e78956e1a750fcc91ec26227483933ceb
158 files changed:
hphp/hack/src/decl/decl_folded_class.ml
hphp/hack/src/decl/decl_fun_utils.ml
hphp/hack/src/decl/decl_fun_utils.mli
hphp/hack/src/decl/decl_nast.ml
hphp/hack/src/decl/decl_pos_utils.ml
hphp/hack/src/decl/decl_to_typing.ml
hphp/hack/src/decl/decl_to_typing.mli
hphp/hack/src/decl/direct_decl_smart_constructors.rs
hphp/hack/src/decl/pos/pos_or_decl.ml
hphp/hack/src/decl/pos/pos_or_decl.mli
hphp/hack/src/decl/shallow_decl.ml
hphp/hack/src/hh_oxidize/convert_type_decl.ml
hphp/hack/src/oxidized_by_ref/copy_types.txt
hphp/hack/src/oxidized_by_ref/decl_visitor/node_impl_gen.rs
hphp/hack/src/oxidized_by_ref/decl_visitor/visitor.rs
hphp/hack/src/oxidized_by_ref/gen/typing_defs_core.rs
hphp/hack/src/oxidized_by_ref/gen/typing_reason.rs
hphp/hack/src/oxidized_by_ref/manual/typing_reason_impl.rs
hphp/hack/src/server/autocompleteService.ml
hphp/hack/src/typing/type_validator.ml
hphp/hack/src/typing/type_visitor.ml
hphp/hack/src/typing/type_visitor.mli
hphp/hack/src/typing/typing.ml
hphp/hack/src/typing/typing_check_decls.ml
hphp/hack/src/typing/typing_defs_core.ml
hphp/hack/src/typing/typing_defs_core.mli
hphp/hack/src/typing/typing_enforceable_hint.ml
hphp/hack/src/typing/typing_env_from_def.ml
hphp/hack/src/typing/typing_extends.ml
hphp/hack/src/typing/typing_inference_env.ml
hphp/hack/src/typing/typing_local_ops.ml
hphp/hack/src/typing/typing_object_get.ml
hphp/hack/src/typing/typing_phase.ml
hphp/hack/src/typing/typing_reason.ml
hphp/hack/src/typing/typing_reason.mli
hphp/hack/src/typing/typing_reified_check.ml
hphp/hack/src/typing/typing_solver.ml
hphp/hack/src/typing/typing_structure.ml
hphp/hack/src/typing/typing_subtype.ml
hphp/hack/src/typing/typing_toplevel.ml
hphp/hack/src/typing/typing_union.ml
hphp/hack/src/typing/typing_variance.mli
hphp/hack/test/decl/abstract_method.php.exp
hphp/hack/test/decl/accept_disposable.php.exp
hphp/hack/test/decl/array_typehints.php.exp
hphp/hack/test/decl/async_and_generator_functions.php.exp
hphp/hack/test/decl/atom.php.exp
hphp/hack/test/decl/auto_ns_use.php.exp
hphp/hack/test/decl/autoimport_in_namespace.php.exp
hphp/hack/test/decl/autoimport_namespaces.php.exp
hphp/hack/test/decl/class_const_declarator_list.php.exp
hphp/hack/test/decl/class_const_int_literals.php.exp
hphp/hack/test/decl/class_const_referencing_global_const.php.exp
hphp/hack/test/decl/class_const_with_parens.php.exp
hphp/hack/test/decl/class_in_namespace.php.exp
hphp/hack/test/decl/class_level_where.php.exp
hphp/hack/test/decl/classes.php.exp
hphp/hack/test/decl/classes_consistent_construct.php.exp
hphp/hack/test/decl/classes_const_attribute.php.exp
hphp/hack/test/decl/classes_const_keyword.php.exp
hphp/hack/test/decl/classes_inferred_constant_types.php.exp
hphp/hack/test/decl/classes_inheritance.php.exp
hphp/hack/test/decl/classes_reified_generics.php.exp
hphp/hack/test/decl/classes_require.php.exp
hphp/hack/test/decl/classes_typeconst.php.exp
hphp/hack/test/decl/classname.php.exp
hphp/hack/test/decl/classname_in_namespace.php.exp
hphp/hack/test/decl/const_attribute.php.exp
hphp/hack/test/decl/const_missing_hint.php.exp
hphp/hack/test/decl/const_null.php.exp
hphp/hack/test/decl/const_string_escaping.php.exp
hphp/hack/test/decl/const_tany.php.exp
hphp/hack/test/decl/constants.php.exp
hphp/hack/test/decl/constraints_mentioning_tparams_in_same_list.php.exp
hphp/hack/test/decl/constraints_with_fully_qualified_name.php.exp
hphp/hack/test/decl/constraints_with_fully_qualified_name_in_namespace.php.exp
hphp/hack/test/decl/denotable_unions.php.exp
hphp/hack/test/decl/deprecated.php.exp
hphp/hack/test/decl/deprecated_string_concat.php.exp
hphp/hack/test/decl/deprecated_string_escaping.php.exp
hphp/hack/test/decl/duplicate_fun_attributes.php.exp
hphp/hack/test/decl/dynamically_callable.php.exp
hphp/hack/test/decl/empty_method_name.php.exp
hphp/hack/test/decl/enforceable_type_const.php.exp
hphp/hack/test/decl/enum_constraint.php.exp
hphp/hack/test/decl/enum_user_attributes.php.exp
hphp/hack/test/decl/enums.php.exp
hphp/hack/test/decl/explicit_type_collection.php.exp
hphp/hack/test/decl/file_mode.php.exp
hphp/hack/test/decl/final_method.php.exp
hphp/hack/test/decl/function_where_constraints.php.exp
hphp/hack/test/decl/functions.php.exp
hphp/hack/test/decl/generic_alias_with_namespace.php.exp
hphp/hack/test/decl/generic_classes.php.exp
hphp/hack/test/decl/generic_method_tparam_scope.php.exp
hphp/hack/test/decl/hhi.hhi.exp
hphp/hack/test/decl/higher_kinded.php.exp
hphp/hack/test/decl/ifc_policied.php.exp
hphp/hack/test/decl/inout.php.exp
hphp/hack/test/decl/interface.php.exp
hphp/hack/test/decl/interfaces.php.exp
hphp/hack/test/decl/like_types.php.exp
hphp/hack/test/decl/memoize_lsb.php.exp
hphp/hack/test/decl/missing_function_typehints.php.exp
hphp/hack/test/decl/multifile.php.exp
hphp/hack/test/decl/multiple_user_attributes_on_class.php.exp
hphp/hack/test/decl/namespace_body_plus_declarations_outside_body.php.exp
hphp/hack/test/decl/namespace_elaboration.php.exp
hphp/hack/test/decl/namespace_global_body_plus_declarations_outside_body.php.exp
hphp/hack/test/decl/namespace_import.php.exp
hphp/hack/test/decl/namespace_keyword.hhi.exp
hphp/hack/test/decl/namespace_self.php.exp
hphp/hack/test/decl/namespace_unscoped.php.exp
hphp/hack/test/decl/namespace_use.php.exp
hphp/hack/test/decl/namespace_use_kind.php.exp
hphp/hack/test/decl/namespaces1.php.exp
hphp/hack/test/decl/namespaces2.php.exp
hphp/hack/test/decl/nested_namespaces.php.exp
hphp/hack/test/decl/nullable_xhp_typehint.php.exp
hphp/hack/test/decl/override_attribute.php.exp
hphp/hack/test/decl/partially_abstract_type_const.php.exp
hphp/hack/test/decl/php_std_lib.hhi.exp
hphp/hack/test/decl/prop_without_visibility_modifier.php.exp
hphp/hack/test/decl/property_declarations.php.exp
hphp/hack/test/decl/property_needs_init.hhi.exp
hphp/hack/test/decl/qualified_name_in_attribute_arg.php.exp
hphp/hack/test/decl/readonly.php.exp
hphp/hack/test/decl/ret_from_kind.php.exp
hphp/hack/test/decl/return_disposable.php.exp
hphp/hack/test/decl/rewritten_tparams.php.exp
hphp/hack/test/decl/self_in_type_constant.php.exp
hphp/hack/test/decl/shape_expression_key_types.php.exp
hphp/hack/test/decl/shape_self.php.exp
hphp/hack/test/decl/shape_type_key_types.php.exp
hphp/hack/test/decl/shapes.php.exp
hphp/hack/test/decl/soft_reified.php.exp
hphp/hack/test/decl/soft_type_hint.php.exp
hphp/hack/test/decl/static_method_call_with_explicit_targ.php.exp
hphp/hack/test/decl/tparams_on_class_and_method.php.exp
hphp/hack/test/decl/trait_use_conflict_resolution.php.exp
hphp/hack/test/decl/traits.php.exp
hphp/hack/test/decl/tuple_hints_broken.php.exp
hphp/hack/test/decl/tuples.php.exp
hphp/hack/test/decl/type_param_attrs.php.exp
hphp/hack/test/decl/typeconst_property_promotion.php.exp
hphp/hack/test/decl/typedefs.php.exp
hphp/hack/test/decl/unnamed_variadic_method_parameter.php.exp
hphp/hack/test/decl/use_type.php.exp
hphp/hack/test/decl/user_attributes_in_namespaces.php.exp
hphp/hack/test/decl/variadic_parameter.php.exp
hphp/hack/test/decl/wildcard_invalid.php.exp
hphp/hack/test/decl/wildcard_invalid_targ.php.exp
hphp/hack/test/decl/xhp.php.exp
hphp/hack/test/decl/xhp_attr.php.exp
hphp/hack/test/decl/xhp_class_const.php.exp
hphp/hack/test/decl/xhp_self.php.exp
hphp/hack/test/decl/yield_deeper.php.exp
hphp/hack/test/typecheck/shape/null_coalesce_optional_in_abstract.php.direct_decl_exp