Check for void/noreturn in conditionals
[hiphop-php.git] / hphp / hack / test / typecheck / instanceof_static_with_reqs.php
blobd3d506f29f216bf5d27a7630b88197a348e5ec57
1 <?hh
3 abstract class BaseField<T> {
5 final public function __construct() {}
7 final public static function fromType($type): this {
8 $class_name = $type->getClassName();
9 $field = new $class_name();
10 hh_show($field);
11 invariant(
12 $field instanceof static,
13 '%s is not a valid %s',
14 $class_name,
15 get_called_class(),
17 hh_show($field);
19 if ($type instanceof HasFoo) {
20 // This illustrates a limitation of the typechecker:
21 // - intersection of this<BaseField> and INeedsFoo
22 invariant(
23 $field instanceof INeedsFoo,
24 'The context arg was provided, but the field doesn\'t support one',
26 hh_show($field);
27 $field->setFoo($type->getFoo());
30 hh_show($field);
31 return $field;
35 interface INeedsFoo<T> {
36 require extends Base;
38 public function setFoo(T $arg): this;