Avoid redundant calls to subtype_method
Summary:
The `Typing_subtype_method.subtype_method` function checks that an "overriding" method signature is compatible with the "overridden" method signature. But we call it redundantly, e.g. in the following
```
class C {
public function foo():mixed { ... }
}
class D extends C {
public function foo():string { ... }
}
class E extends D {
}
```
we check not only that the signature of `D::foo` is compatible with `C::foo`, but also that `E::foo` is compatible with `D::foo`. But as the signature of `E::foo` is just copied down from `D::foo`, this is just an identity check, and so completely redundant.
There is an easy way to avoid the redundant checks: just look at the `ce_origin` field in the class element. When these are the same in parent and child, then any override checks are redundant.
The override checks (which are dominated by subtyping, but include various other tests) are expensive: on large codebases the overall saving in total type check time is over 15%.
Reviewed By: vsiles
Differential Revision:
D22358580
fbshipit-source-id:
5ce78f528de3fd481d34736df3823e5f9873e2bd