Improve typing of array_map
Summary:
Typing of `array_map` used to be completely broken. It was basically possible to pass a function whose parameter types were incompatible with the types of values in the containers being mapped over. E.g., the following function would type check:
```
<?hh // strict
function test<TA, TB, TC>((function(TA): TB) $f, vec<TC> $x): void {
array_map($f, $x);
}
```
Furthermore, `array_map` over literals would sometimes not work, e.g.:
```
<?hh // strict
function test(): void {
array_map($x ==> $x, Vector {'foo', 42});
}
```
would fail to type check:
```
File "hphp/hack/test/typecheck/array_map8.php", line 4, characters 24-41:
Some elements in this Vector are incompatible (Typing[4110])
File "hphp/hack/test/typecheck/array_map8.php", line 4, characters 32-36:
This is a string
File "hphp/hack/test/typecheck/array_map8.php", line 4, characters 39-40:
It is incompatible with an int
```
(The same error would be reported if one used `vec` instead of `Vector` but bizarrely wouldn't if one used `varray`.)
This diff fixes those errors.
Reviewed By: andrewjkennedy
Differential Revision:
D7655423
fbshipit-source-id:
a2966779b1c68ec9045ddc39a13b5baebc980680