Error on self::class on non final classes
[hiphop-php.git] / hphp / hack / test / typecheck / constmap.php
blob47f45aa2f4c80666747fcf70e200811fd8fc73fe
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 function covariance(ConstMap<arraykey, mixed> $x): void {}
13 function test1(Map<string, int> $c): ConstMap<arraykey, mixed> {
14 covariance($c);
15 return $c;
17 function test2(ImmMap<string, int> $c): ConstMap<arraykey, mixed> {
18 covariance($c);
19 return $c;
22 class C<Tv> {
23 public function covariance(ConstMap<arraykey, Tv> $x): void {}
24 public function test1<Tu as Tv>(Map<string, Tu> $c): ConstMap<arraykey, Tv> {
25 $this->covariance($c);
26 return $c;
28 public function test2<Tu as Tv>(
29 ImmMap<string, Tu> $c
30 ): ConstMap<arraykey, Tv> {
31 $this->covariance($c);
32 return $c;