Generic way to check required reactivity for arguments at callsites
commit4b5119c533cf8887a7ae2f52298c7e3ac2acd387
authorVladimir Matveev <vladima@fb.com>
Fri, 20 Apr 2018 22:39:49 +0000 (20 15:39 -0700)
committerHhvm Bot <hhvm-bot@users.noreply.github.com>
Fri, 20 Apr 2018 22:43:41 +0000 (20 15:43 -0700)
tree2174a63478bbf1350be1b08bd28f32a20599f9e1
parent2cfb1e03708d76da1b0f373ab8d838e282c16acc
Generic way to check required reactivity for arguments at callsites

Summary:
This diff adds several things:
- new `fp_rx_condition` property on function parameters which is set if function parameter has some constraint that should be satisfied in order to treat function call as reactive
- at call site we check if argument type is a subtype of parameter type with augmented with constraint - i.e. for this case
```
<<__RxLocal, __OnlyRxIfArgs>>
function g(
  <<__OnlyRxIfRxFunc>> (function(): int) $f
): void { ...}

f(() ==> 1);
```

we'll check if inferred type of argument $f is a subtype of `<__RxLocal>(function(): int)`.

This allows us to:
-  handle `<<____OnlyRxIfRxFunc>>` parameters when parameter type is nullable function type
- set the base for the next step - parameters annotated with `<<__OnlyRxIfImpl(C::class)>>` where argument to function should be subtype of `C` in order for call to be reactive.

Reviewed By: jamesjwu

Differential Revision: D7714071

fbshipit-source-id: f19f9a0596eea46b3cb962a622d84c656191fc6a
13 files changed:
hphp/hack/src/decl/decl.ml
hphp/hack/src/decl/decl_hint.ml
hphp/hack/src/typing/tast_expand.ml
hphp/hack/src/typing/typing.ml
hphp/hack/src/typing/typing_defs.ml
hphp/hack/src/typing/typing_reactivity.ml
hphp/hack/src/typing/typing_utils.ml
hphp/hack/test/typecheck/reactive/nullable_mayberx1.php [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/nullable_mayberx1.php.exp [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/nullable_mayberx2.php [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/nullable_mayberx2.php.exp [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/nullable_mayberx3.php [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/nullable_mayberx3.php.exp [new file with mode: 0644]