Please sign in to comment.
`_` as implicit instantiation
Summary: This diff adds typechecking semantics for `_`. It is intended to be used when the user doesn't know how to annotate a call to a constructor or function. Specifically, this will help when annotating exported calls that don't require annotations on _every_ type parameter. `_` allows the user to explicitly ask for a type variable to be instantiate for a type parameter. We have two relevant functions in flow that are used when calling a polymorphic function or constructor: `instantiate_poly` and `instantiate_poly_with_targs`. `instantiate_poly` creates fresh tvars for each parameter and then calls `instantiate_poly_with_targs`. This is how we create type variables to calls to polymorphic functions that don't specify explicit arguments. Our current implementation is "all or nothing": you either provide all concrete type arguments, or we implicitly instantiate all of them. `_` changes this to allow the user to specify only some and not others. Reviewed By: samwgoldman Differential Revision: D10109218 fbshipit-source-id: 0b3fbcbaed8481aded5ad29967a902bdb26bf5b0
- Loading branch information...
Showing with 160 additions and 46 deletions.
- +4 −0 src/common/reason.ml
- +1 −0 src/common/reason.mli
- +8 −4 src/typing/debug_js.ml
- +9 −11 src/typing/flow_error.ml
- +27 −3 src/typing/flow_js.ml
- +12 −6 src/typing/statement.ml
- +5 −3 src/typing/type.ml
- +1 −1 src/typing/type_annotation.ml
- +12 −3 src/typing/type_mapper.ml
- +2 −0 src/typing/type_mapper.mli
- +6 −2 src/typing/type_visitor.ml
- +1 −0 src/typing/type_visitor.mli
- +52 −9 tests/implicit_instantiation/implicit_instantiation.exp
- +20 −4 tests/implicit_instantiation/test.js
Oops, something went wrong.