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