One more fix for `super`
commit9e03090fc4f2a6c8858617457502351647302142
authorJez Ng <jezng@fb.com>
Wed, 22 Apr 2015 23:12:19 +0000 (22 16:12 -0700)
committerhhvm-bot <hhvm-bot@fb.com>
Thu, 23 Apr 2015 08:00:41 +0000 (23 01:00 -0700)
treec264037e1b7e42ff6f5a2594a14ff212175fabe5
parent8271f080345df7e6e7c8e1f3a133b225f72a561a
One more fix for `super`

Summary: Since `Tmixed` is always a solution for a `super`-constrained
type, we want to make sure that the `super` constraint always results in
the type growing, and never raises a type error in and of itself (it
needs to encounter a mismatching type hint). Thus we ensure that the
constrained type is always a Tunresolved; if not, we wrap it in one.

We *do* instantiate generic types to Tvars of Tunresolved, but if we
unify with (as opposed to subtype against) a not-Tunresolved type, we
end up with a Tvar of not-Tunresolved. This will happen when e.g.
unifying Foo<T> with Foo<int>, where T is invariant w.r.t. Foo.

Reviewed By: @elgenie

Differential Revision: D2015378
hphp/hack/src/typing/typing.ml
hphp/hack/src/typing/typing_instantiate.ml
hphp/hack/test/typecheck/super_constraint_9.php [new file with mode: 0644]
hphp/hack/test/typecheck/super_constraint_9.php.exp [new file with mode: 0644]