Disallow ... without type in function typehints
[hiphop-php.git] / hphp / hack / test / typecheck / generic_subtyping4.php
blob9ef616894b0dda3ae0eee65fdf102966ab08e552
1 <?hh // strict
2 /**
3 * Copyright (c) 2014, Facebook, Inc.
4 * All rights reserved.
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 class TestGeneric<T> {
13 private T $obj;
15 public function __construct(T $obj) {
16 $this->obj = $obj;
19 public function get(): T {
20 return $this->obj;
24 class X<T, Tc as TestGeneric<T> > {
25 public Vector<T> $vec;
27 public function __construct(Vector<Tc> $tests) {
28 $results = Vector {};
29 foreach ($tests as $test) {
30 $results[] = $test->get();
32 $this->vec = $results;
35 public function getVector(): Vector<T> {
36 return $this->vec;
41 function testBool(bool $arg): void {}
43 function test(): void {
44 $objs = Vector {
45 new TestGeneric(1),
46 new TestGeneric(2),
49 $results = (new X($objs))->getVector();
50 foreach ($results as $result) {
51 // Hack should complain it's an int !
52 testBool($result);