3 * Copyright (c) 2014, Facebook, Inc.
6 * This source code is licensed under the MIT license found in the
7 * LICENSE file in the "hack" directory of this source tree.
12 // Test that the typechecker can correctly handle ImmVector.
16 function h1(): ImmVector
<string> {
17 return ImmVector
{'hello', 'world'};
20 function h2(int $k) : void
{}
22 function h3(string $v) : void
{}
24 // Test that ImmVector {} : ImmVector<int>
26 function emptyfv(): ImmVector
<int> {
30 // Test array-like access.
32 function simple(ImmVector
<int> $fv) : int {
38 function nested(): ImmVector
<ImmVector
<string>> {
39 return ImmVector
{h1(), ImmVector
{'a', 'b', 'c'}, ImmVector
{}};
45 $v = ImmVector
{1, 2, 3, 4, 5};
53 // Foreach over a FV with both key and value.
55 function feach(ImmVector
<string> $vec) : void
{
56 foreach ($vec as $k => $v) {
64 function lsyntax(ImmVector
<int> $fv) : void
{
68 // Generic FVs are covariant
76 function covariance(ImmVector
<B
> $fvb) : ImmVector
<A
> {