Shopify / tapioca

The swiss army knife of RBI generation
MIT License
746 stars 128 forks source link

Skip auto-generation for methods with annotations #1986

Closed amomchilov closed 3 months ago

amomchilov commented 3 months ago

The RBIs auto-generated by Tapioca can conflict with hand-written annotations, such as from RBI central. This causes Sorbet to complain about method redefinition, with error 4010.

We should find a way to minimize or fix these collisions.

Solution ideas

1. Skip auto-generation for methods with annotations

Concern: the real method's declaration (i.e. the implementation code from the gem) can change in a way that makes the hand-written annotation stale/incorrect.

Solution idea: associate the hand-written annotation to a copy of the method declaration. If that declaration doesn't match what's declared by the gem, then we know that it went stale.

2. Improve auto-generation, to require fewer annotations

Lots of dynamically defined methods end up with (*args, **kwargs, &block) declarations. If we can improve on these, we'd have less of a need for manual annotations in the first place.

Morriar commented 3 months ago

I think this context can be moved to https://github.com/Shopify/tapioca/issues/1516?