An initial implementation of linearization
commit3d2a885f9227511bf8cb49ff94839f193382b9c4
authorJames Wu <jjwu@fb.com>
Fri, 14 Sep 2018 02:38:03 +0000 (13 19:38 -0700)
committerHhvm Bot <hhvm-bot@users.noreply.github.com>
Fri, 14 Sep 2018 02:43:34 +0000 (13 19:43 -0700)
tree81cdde93c7d578168fcbbc22631a5378e9d74ffb
parent2a0c47e0de1ee73cd8772a1b005f085dbcc370c8
An initial implementation of linearization

Summary:
This diff introduces a new field "dc_linearization" to the decl_defs. We won't start storing this in the decl_heap in prod until we use it for a purpose, but the first step is creating an implementation of linearization that I can test.

For each class, we store a list of strings representing the classes by method resolution order. For now this list only contains direct extends ancestors, but the next diffs add more and more to linearization until it's full featured.

We calculate the linearization of a class from the linearization of its parent classes, (and later, traits, require extends, and anything else that a class can inherit from).

After implementing an initial version of this, my goal will be to use it to reimplement decl_inherit.ml, as well as introduce new checks in a step called linearization analysis.

Reviewed By: kmeht

Differential Revision: D9691089

fbshipit-source-id: 75b02ece31e46212445472598619c468373e21a3
12 files changed:
hphp/hack/src/decl/decl.ml
hphp/hack/src/decl/decl_class.ml
hphp/hack/src/decl/decl_defs.ml
hphp/hack/src/decl/decl_linearize.ml [new file with mode: 0644]
hphp/hack/src/decl/decl_linearize.mli [new file with mode: 0644]
hphp/hack/src/decl/decl_pos_utils.ml
hphp/hack/src/hh_single_type_check.ml
hphp/hack/src/options/globalOptions.ml
hphp/hack/src/options/globalOptions.mli
hphp/hack/src/options/typecheckerOptions.ml
hphp/hack/test/mro/basic_interfaces.php [new file with mode: 0644]
hphp/hack/test/mro/basic_interfaces.php.exp [new file with mode: 0644]