Register capabilities after saving env for anon. fun
commitb9b8c127a772dd2ca11a1403d0525f2020af4b7f
authorLeo Osvald <leoo@fb.com>
Wed, 11 Nov 2020 22:14:19 +0000 (11 14:14 -0800)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Wed, 11 Nov 2020 22:24:14 +0000 (11 14:24 -0800)
tree68d7880d321a00146a9021f8d42ad544de9be1d8
parent452f50801cf84a74a1144444a960d8ed25eec569
Register capabilities after saving env for anon. fun

Summary:
This was mistakenly done too soon, before the locals are saved
(so that they could be restored after type-checking lambdas).
The fixed version is more complicated because we need to thread through
either a `Tfun` or a capability (implicit parameters); I chose the former
as it offers a slight perf win (we don't need to construct a `Tfun` twice).

To avoid ad-hoc changes to signatures and munging returned data across
*several* higher-order functions, generalize the return type of `anon_make`
as `env * 'a`, which is now consistent with other helper functions around it.

Reviewed By: vassilmladenov

Differential Revision: D24881024

fbshipit-source-id: ead1b424aa0bca4ac71c6fb0c1f90358ccf19915
hphp/hack/src/typing/typing.ml
hphp/hack/src/typing/typing_env.ml
hphp/hack/src/typing/typing_env.mli
hphp/hack/test/typecheck/coeffects/closures_restore_env.php [new file with mode: 0644]
hphp/hack/test/typecheck/coeffects/closures_restore_env.php.exp [new file with mode: 0644]