Move from symbol-level modules to file level modules
commit52376094548724accfbd3d51de4bf177e8bff30d
authorHunter Goldstein <hgoldstein@fb.com>
Wed, 8 Dec 2021 20:57:14 +0000 (8 12:57 -0800)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Wed, 8 Dec 2021 21:01:11 +0000 (8 13:01 -0800)
treee54c2d6897935b084ccefbe15a143f37ca09f68a
parent8a9eb8c6a3faee674fb35c115fb4fa10e67c97ff
Move from symbol-level modules to file level modules

Summary:
TSIA; ultimately, we want modules to be declared *out of band*, that is outside of normal Hack source code. This is a step towards that.

There were two options here for how to get module info to the right decls:
1. Determine the module up front when parsing the file and thread it through lowering / whatever
2. Keep the file attributes on the AST and use them when needed.

(1) seems like the "good" thing to do here, but (2) was already partially done (functions and classes both kept file attributes around, typedefs I had to add it).

The main annoyance here was threading through file attributes: we drop them in a few places, and they're set erratically. This *should* keep them around long enough s.t. we can fill in module info.

There are a few follow up tasks (which are noted in source code).
1. Record handling is just non-existent. Given HHVM record support was removed, I'm not particularly concerned.
2. We no longer error when giving the `__Module` attribute more than one argument.

Reviewed By: andrewjkennedy

Differential Revision: D32506191

fbshipit-source-id: 701979e5f5ee7c2e1315302c88763f81cef2c45f
93 files changed:
hphp/hack/src/annotated_ast/aast.ml
hphp/hack/src/decl/decl.ml
hphp/hack/src/decl/decl_nast.ml
hphp/hack/src/decl/decl_nast.mli
hphp/hack/src/decl/direct_decl_smart_constructors.rs
hphp/hack/src/decl/shallow_decl.ml
hphp/hack/src/hh_single_decl.ml
hphp/hack/src/naming/naming.ml
hphp/hack/src/naming/naming_attributes_params.ml
hphp/hack/src/oxidized/aast_visitor/node_impl_gen.rs
hphp/hack/src/oxidized/aast_visitor/node_mut_impl_gen.rs
hphp/hack/src/oxidized/gen/aast.rs
hphp/hack/src/oxidized_by_ref/gen/aast.rs
hphp/hack/src/parser/lowerer/lowerer.rs
hphp/hack/src/parser/rust_parser_errors.rs
hphp/hack/src/providers/decl_provider.ml
hphp/hack/src/typing/nast_check/attribute_nast_checks.ml
hphp/hack/src/typing/typing_toplevel.ml
hphp/hack/src/typing/typing_type_wellformedness.ml
hphp/hack/src/typing/typing_typedef.ml
hphp/hack/src/typing/typing_variance.ml
hphp/hack/test/decl/module_attr.php
hphp/hack/test/decl/module_attr.php.exp
hphp/hack/test/decl/module_enums.php [copied from hphp/hack/test/typecheck/modules/module_enums.php with 69% similarity]
hphp/hack/test/decl/module_enums.php.exp
hphp/hack/test/decl/module_enums.php.typecheck.exp
hphp/hack/test/decl/module_hint.php
hphp/hack/test/decl/module_hint.php.exp
hphp/hack/test/decl/module_hint.php.typecheck.exp
hphp/hack/test/decl/module_methods.php
hphp/hack/test/decl/module_methods.php.exp
hphp/hack/test/decl/module_methods.php.typecheck.exp
hphp/hack/test/decl/module_properties.php
hphp/hack/test/decl/module_properties.php.exp
hphp/hack/test/decl/module_properties.php.typecheck.exp
hphp/hack/test/decl/module_static_prop.php
hphp/hack/test/decl/module_static_prop.php.exp
hphp/hack/test/decl/module_static_prop.php.typecheck.exp
hphp/hack/test/decl/submodules.php
hphp/hack/test/decl/submodules.php.exp
hphp/hack/test/decl/submodules.php.typecheck.exp
hphp/hack/test/nast/coeffects/ctx_alias.php.exp
hphp/hack/test/nast/coeffects/ctx_const_naespacing.php.exp
hphp/hack/test/nast/higher_kinded_type_constraints1.php.exp
hphp/hack/test/nast/higher_kinded_type_constraints2.php.exp
hphp/hack/test/tast/dict_attribute.php.exp
hphp/hack/test/tast/global_inference/reinfer_types/unsafe_type_fixme.php.exp
hphp/hack/test/tast/shapes_special_functions.php.exp
hphp/hack/test/tast/typedef.php.exp
hphp/hack/test/typecheck/modules/basic_fun_call.php
hphp/hack/test/typecheck/modules/basic_fun_call.php.exp
hphp/hack/test/typecheck/modules/fun_pointer.php
hphp/hack/test/typecheck/modules/fun_pointer.php.exp
hphp/hack/test/typecheck/modules/module_attr.php
hphp/hack/test/typecheck/modules/module_attr.php.direct_decl_exp
hphp/hack/test/typecheck/modules/module_attr_bad.php
hphp/hack/test/typecheck/modules/module_attr_bad.php.exp
hphp/hack/test/typecheck/modules/module_bad_arity.php
hphp/hack/test/typecheck/modules/module_bad_arity.php.exp
hphp/hack/test/typecheck/modules/module_bad_override.php
hphp/hack/test/typecheck/modules/module_bad_override.php.exp
hphp/hack/test/typecheck/modules/module_bad_visibility.php
hphp/hack/test/typecheck/modules/module_bad_visibility.php.exp
hphp/hack/test/typecheck/modules/module_class_expr.php
hphp/hack/test/typecheck/modules/module_class_expr.php.exp
hphp/hack/test/typecheck/modules/module_constructor.php
hphp/hack/test/typecheck/modules/module_constructor.php.exp
hphp/hack/test/typecheck/modules/module_enums.php [copied from hphp/hack/test/decl/module_enums.php with 55% similarity]
hphp/hack/test/typecheck/modules/module_enums.php.exp
hphp/hack/test/typecheck/modules/module_file_attr.php [new file with mode: 0644]
hphp/hack/test/typecheck/modules/module_file_attr.php.exp [new file with mode: 0644]
hphp/hack/test/typecheck/modules/module_hint.php
hphp/hack/test/typecheck/modules/module_hint.php.exp
hphp/hack/test/typecheck/modules/module_inheritance.php
hphp/hack/test/typecheck/modules/module_inheritance.php.exp
hphp/hack/test/typecheck/modules/module_interfaces.php
hphp/hack/test/typecheck/modules/module_interfaces.php.exp
hphp/hack/test/typecheck/modules/module_internal_class.php
hphp/hack/test/typecheck/modules/module_internal_class.php.exp
hphp/hack/test/typecheck/modules/module_methods_basic.php
hphp/hack/test/typecheck/modules/module_methods_basic.php.exp
hphp/hack/test/typecheck/modules/module_properties.php
hphp/hack/test/typecheck/modules/module_properties.php.exp
hphp/hack/test/typecheck/modules/module_static_method.php
hphp/hack/test/typecheck/modules/module_static_method.php.exp
hphp/hack/test/typecheck/modules/module_static_prop.php
hphp/hack/test/typecheck/modules/module_static_prop.php.exp
hphp/hack/test/typecheck/modules/module_traits.php
hphp/hack/test/typecheck/modules/module_traits.php.exp
hphp/hack/test/typecheck/modules/module_typedef.php
hphp/hack/test/typecheck/modules/module_typedef.php.exp
hphp/hack/test/typecheck/modules/submodules.php
hphp/hack/test/typecheck/modules/submodules.php.exp