Check for void/noreturn in conditionals
[hiphop-php.git] / hphp / hack / test / typecheck / class_prop_as_this.php
blobc6551189712807f80002409f001244b5a4ac4a21
1 <?hh // strict
3 // The test proves that it is safe to allow the 'this' type as a public
4 // property. Attempting to assign to a property of type 'this' will fail
5 // if they are not the same expression dependent type.
6 abstract class C {
7 public function __construct(public this $x) {}
9 public function test(C $c1, C $c2, this $static): void {
10 // This works because both are known to be of type <static>
11 $static->x = $this->x;
12 hh_show($static->x);
13 hh_show($this->x);
15 // But since we don't know if $c1 and $c2 refer to the same type this is an
16 // error.
17 $c1->x = $c2->x;