Summary: `getThis` is an idiom for allowing Builder sub-classes to jump through the hoops of covariance plus java generics with self types. It's declared as abstract in the (generic) inner `Builder` class of a root class, and subclasses declare generic `Builder`s that inherit from the generic root `Builder` and trivially implement this method by returning `this`. Obviously, this returns conditional ownership (if `this` is owned, then the return value is owned). The way it's typically used is ``` T foo() { ... return getThis(); } ``` However, because abstract methods need dynamic dispatch for proper summarisation, we miss all that. A workaround was been implemented in D8947992 (see that for context), but it was buggy -- it required that the LHS type in the assignment ``` lhs = this.getThis(); ``` is the same as the type of `this`, but this is too strict (eg, when using casts). Here, the condition is changed to requiring that the return type of the method is the same as the type of `this`. We also avoid asking for the `procdesc` as everything needed is in the attributes. Reviewed By: jberdine Differential Revision: D18450737 fbshipit-source-id: e67f0495cmaster
parent
7a5ce51901
commit
1fb344289e
Loading…
Reference in new issue