Support type constraint (typing, part 2)
commit6090d205065c1e947e4eff5ff4cd28dbe39c3bb9
authorVincent Siles <vsiles@fb.com>
Wed, 24 Jun 2020 17:05:25 +0000 (24 10:05 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Wed, 24 Jun 2020 17:07:55 +0000 (24 10:07 -0700)
tree2cd958f0409b9043fb0daa270471f0b1f4dba0f0
parent0872ecd1212cae37f770386110600e45927f32c0
Support type constraint (typing, part 2)

Summary:
We currently only support reify modifier on case type T statements.
This diff allows to add constraint to such statements.
The goal is to support things like:
```
class C {
  enum E {
    case type T as num;
    case T val;
    :I(type T = int); // OK
    :S(type S = string); // KO
  }

  public static function add<TP as static:E>(TP $x, TP $y) : num {
    $x = static:E::val($x); // $x:T as num
    $y = static:E::val($y); // $y:T as num
    return $x + $y; // should be num
}
```
In this diff, I introduce the checking of the PU at use site (which
allow to type check `C::add`).

Reviewed By: mpu

Differential Revision: D21884927

fbshipit-source-id: c26999f3740a069ef0d8d00d7d9de621bad542b1
hphp/hack/src/typing/typing_pocket_universes.ml
hphp/hack/src/typing/typing_subtype.ml
hphp/hack/test/pocket_universes/typing/constraints_usage.bad.php [new file with mode: 0644]
hphp/hack/test/pocket_universes/typing/constraints_usage.bad.php.exp [new file with mode: 0644]
hphp/hack/test/pocket_universes/typing/constraints_usage.good.php [new file with mode: 0644]
hphp/hack/test/pocket_universes/typing/constraints_usage.good.php.exp [new file with mode: 0644]
hphp/hack/test/pocket_universes/typing/pu_in_lambda.good.php [new file with mode: 0644]
hphp/hack/test/pocket_universes/typing/pu_in_lambda.good.php.exp [new file with mode: 0644]