AST changes to support optional type annotations for collection expressions
commit92d95cdd8182e729bdc05a43f2e26842b6ae5fb1
authorMatt Schellhas <rms@fb.com>
Wed, 27 Feb 2019 23:49:06 +0000 (27 15:49 -0800)
committerHhvm Bot <hhvm-bot@users.noreply.github.com>
Wed, 27 Feb 2019 23:55:19 +0000 (27 15:55 -0800)
tree8b8d3df4127879e5e7e31168834e43129a4f81d7
parent5763173f8f3dc1d8145d57ea82851f9859108477
AST changes to support optional type annotations for collection expressions

Summary:
The front end work to support optional explicit type annotations for stuff like `vec<string>[...]`.

The typechecking algorithm performs super-linearly when trying to infer the unification of things that are slightly different. Usually this isn't a problem because there are only a few things to unify. But sometimes there are more than a few things to unify... like what happens when a collection expression contains many subtypes of a common base. In some real world cases, this prevents the algorithm from finishing in a practical timeframe.

While people work to fix the super-linearity problem, allowing type hints for collection expressions should provide a work-around.

Reviewed By: oulgen

Differential Revision: D14093176

fbshipit-source-id: f81bad3ffca599df0b8133ed29581c3ee34c2b64
29 files changed:
hphp/hack/src/annotated_ast/aast.ml
hphp/hack/src/annotated_ast/aast_defs.ml
hphp/hack/src/annotated_ast/aast_mapper.ml
hphp/hack/src/hhbc/ast_constant_folder.ml
hphp/hack/src/hhbc/closure_convert.ml
hphp/hack/src/hhbc/emit_expression.ml
hphp/hack/src/hhbc/emit_property.ml
hphp/hack/src/hhbc/emit_xhp.ml
hphp/hack/src/hhbc/hhbc_hhas.ml
hphp/hack/src/hhbc/instruction_sequence.ml
hphp/hack/src/naming/ast_to_nast.ml
hphp/hack/src/naming/naming.ml
hphp/hack/src/naming/nast.ml
hphp/hack/src/naming/nast_pos_mapper.ml
hphp/hack/src/parser/ast.ml
hphp/hack/src/parser/ast_visitor.ml
hphp/hack/src/parser/full_fidelity_ast.ml
hphp/hack/src/parser/full_fidelity_syntax_error.ml
hphp/hack/src/parser/full_fidelity_syntax_error.mli
hphp/hack/src/typing/nastCheck.ml
hphp/hack/src/typing/nastInitCheck.ml
hphp/hack/src/typing/tast_check/basic_reactivity_check.ml
hphp/hack/src/typing/typing.ml
hphp/hack/src/typing/typing_get_locals.ml
hphp/hack/test/tast/add_vector.php.exp
hphp/hack/test/tast/construct_unknown_class.php.exp
hphp/hack/test/tast/unresolved_grown_after_lambda.php.exp
hphp/hack/test/typecheck/explicit_type_collection_intrinsic.php.exp
hphp/hack/test/typecheck/explicit_type_collection_map.php.exp