Avoid using decl_class_type wherever possible
commit53071fd3a5db038842a498452b0cb87420b2069c
authorJake Bailey (Hacklang) <jakebailey@fb.com>
Wed, 17 Apr 2019 19:25:00 +0000 (17 12:25 -0700)
committerHhvm Bot <hhvm-bot@users.noreply.github.com>
Wed, 17 Apr 2019 19:32:36 +0000 (17 12:32 -0700)
tree1306b99d3860a18e249108971e59d75ca8927c39
parent99de018170a2ef92b81fdb64c0484258657c984e
Avoid using decl_class_type wherever possible

Summary:
When `shallow_class_decl` is disabled, we must avoid lazily looking up shallow class declarations using `Shallow_classes_heap.get`. As of {D13570861}, this function throws an exception when `shallow_class_decl` is disabled, since without a shared-memory store of shallow classes, we have no guarantee that we aren't wasting time needlessly re-parsing the class we are trying to look up.

When `shallow_class_decl` is enabled, we must avoid computing `decl_class_type`s or `Typing_defs.class_type`s, since we would like to replace all uses of them with lazy lookup. Computing and storing the legacy class types will waste time and memory.

To deal with this, we represent classes in Typing_classes_heap with a new type, `class_type_variant`:

```
type class_type_variant =
  | Lazy of lazy_class_type
  | Eager of class_type
```

When `shallow_class_decl` is enabled, we only ever construct the `Lazy` variant. When it is disabled, we only ever construct the `Eager` variant.

Wherever we currently use `decl_class_type` directly (for example, in `Ppl_check`), we replace those uses with `Typing_classes_heap.t`, so that when shallow class decl is enabled, we will lazily look up the information instead of relying on the eager-class-decl store being populated.

Previously, the `dc_ppl` field was not propagated to `Typing_defs.class_type` because the `Ppl_check` module used it on `decl_class_type` directly. Since we are now using `Typing_classes_heap.t` to abstract over whether `shallow_class_decl` is enabled, it's necessary to propagate this field to the typing `class_type`, and we add the field `tc_ppl` and the accessor `Typing_classes_heap.ppl`.

Reviewed By: pittsw

Differential Revision: D14876508

fbshipit-source-id: 2a3b3a0f1d0649e51da7aa83408b02a2035f7d18
hphp/hack/src/decl/decl_class.ml
hphp/hack/src/decl/shallow_classes_heap.mli
hphp/hack/src/server/serverCommand.ml
hphp/hack/src/typing/pp_type.ml
hphp/hack/src/typing/tast_check/ppl_check.ml
hphp/hack/src/typing/typing_classes_heap.ml
hphp/hack/src/typing/typing_classes_heap.mli
hphp/hack/src/typing/typing_defs.ml
hphp/hack/src/typing/typing_lazy_heap.ml