Sound Dynamic: support subtyping to dynamic when checking overrides
commit23eda6e530c41fe022e01731d4bf3d60e75a9840
authorAndrew Kennedy <akenn@fb.com>
Thu, 4 Feb 2021 18:54:16 +0000 (4 10:54 -0800)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Thu, 4 Feb 2021 18:56:42 +0000 (4 10:56 -0800)
treeb7978b20a88565f6088f94f1bd386d9b479ad971
parentbfd338ff5eb2cba717a0275f00d37165138f309f
Sound Dynamic: support subtyping to dynamic when checking overrides

Summary: The Sound Dynamic design supports subtyping `t <: dynamic` given sufficient conditions on `t` and an *explicit* target type of `dynamic`. Such explicit targets include method overrides, for example, overriding a parameter type of `int` with the more general `dynamic`, or overriding a return type `dynamic` with the more specific `int`. When checking overrides, we therefore pass the special flag `CoerceToDynamic` to the subtyping function.

Differential Revision: D26252974

fbshipit-source-id: c51dd0637484d8c820078041d0963fb661d9f213
hphp/hack/src/typing/typing_subtype.ml
hphp/hack/test/sound_dynamic/typing/override_sound_dynamic.php [new file with mode: 0644]
hphp/hack/test/sound_dynamic/typing/override_sound_dynamic.php.exp [new file with mode: 0644]