Error on self::class on non final classes
[hiphop-php.git] / hphp / hack / test / typecheck / generic_subtyping5.php
blob1b0348d1fd3bc62ed15e1311e705d2aa247ca6e7
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;
38 function testBool(bool $arg): void {}
40 function test(): void {
41 $objs = Vector {
42 new TestGeneric(1),
43 new TestGeneric(2),
46 $results = (new X($objs))->vec;
47 foreach ($results as $result) {
48 // Hack should complain it's an int !
49 testBool($result);