A generic type parameter is a subtype of mixed
commita04961b3c0dd65f282c74e5e3861ff00da91ae73
authorSasha Manzyuk <manzyuk@fb.com>
Mon, 6 Aug 2018 15:38:28 +0000 (6 08:38 -0700)
committerHhvm Bot <hhvm-bot@users.noreply.github.com>
Mon, 6 Aug 2018 15:42:05 +0000 (6 08:42 -0700)
tree149e9cae5709aff9bb5c911c712001a49b16de96
parent4b13df838056d33852d2b548adf924ae330aea32
A generic type parameter is a subtype of mixed

Summary: This is similar to D9148257 but for generic type parameters.  To be able to satisfy the constraint `T <: t`, where `t` is equivalent to but syntactically different from `mixed = ?nonnull` (e.g., `t` is a type parameter `T'` constrained using `super nonnull`), I'm suggesting to add `?nonnull` as an implicit upper bound to `T`.  The preserve the error messages I'm suggesting to try this implicit bound immediately before giving up having exhausted the list of explicit upper bounds.

Reviewed By: andrewjkennedy

Differential Revision: D9148258

fbshipit-source-id: 71b2926bd1956a4fc02a6c909ef9da5754d6c601
hphp/hack/src/typing/typing_subtype.ml
hphp/hack/test/typecheck/generic_subtype_mixed_bad.php [new file with mode: 0644]
hphp/hack/test/typecheck/generic_subtype_mixed_bad.php.exp [new file with mode: 0644]
hphp/hack/test/typecheck/generic_subtype_mixed_good.php [new file with mode: 0644]
hphp/hack/test/typecheck/generic_subtype_mixed_good.php.exp [new file with mode: 0644]