Check for void/noreturn in conditionals
[hiphop-php.git] / hphp / hack / test / typecheck / this_chain.php
blobb97340c8233c9242222d8beacbb0e10c84ce89db
1 <?hh // strict
2 /**
3 * Copyright (c) 2014, Facebook, Inc.
4 * All rights reserved.
6 * This source code is licensed under the BSD-style license found in the
7 * LICENSE file in the "hack" directory of this source tree. An additional grant
8 * of patent rights can be found in the PATENTS file in the same directory.
12 class Base {
13 public function setA(): this { return $this; }
16 class Child1 extends Base {}
17 class Child2 extends Base {}
18 class Child3 extends Base {}
19 class Child4 extends Base {}
21 function foo(int $x): Base {
22 switch ($x) {
23 case 0:
24 $thing = new Child1();
25 break;
26 case 1:
27 $thing = new Child2();
28 break;
29 case 2:
30 $thing = new Child3();
31 break;
32 default:
33 $thing = new Child4();
34 break;
36 return $thing->setA()->setA()->setA()->setA();