Hack prefers "super" to "as" constraints on type parameters, and should not
commitbb428c78ae2e4e160597bbbb2c5218304499a1c0
authorAndrew Kennedy <akenn@fb.com>
Wed, 8 Jun 2016 22:25:09 +0000 (8 15:25 -0700)
committerHhvm Bot <hhvm-bot-bot@fb.com>
Wed, 8 Jun 2016 22:40:59 +0000 (8 15:40 -0700)
tree725933c94b7c6eba7c5c2cfd298164b498c8d4d8
parent95a45ca7139e854c04cfefff521bc266ee7bdde8
Hack prefers "super" to "as" constraints on type parameters, and should not

Summary:
A function with signature
```
Foo<Tu, Tv super Tu>(...)
```
should behave the same way as
```
Foo<Tu as Tv, Tv>(...)
```

But in the example in the task, the former works but the latter fails when invoked.

The root cause was an asymmetry in the handling of constraints in typing_generic_constraint, where the subtype was passed in as pre-expanded
in the SUPER case but not expanded (i.e. as a type variable) in the AS case. The fix is to pass in the subtype as pre-expanded in both cases.

Reviewed By: dlreeves

Differential Revision: D3406590

fbshipit-source-id: 00338ada14bed9736e46d5a786fcb53b7b7c88a8
hphp/hack/src/typing/typing_generic_constraint.ml
hphp/hack/test/typecheck/constraints/super_as_covariant.php [new file with mode: 0644]
hphp/hack/test/typecheck/constraints/super_as_covariant.php.exp [new file with mode: 0644]