Rewrite `attr_reader` and friends into `def` methods
@amomchilov is already working on this.
Since Jun 10, 2024.
- Dominant language
- Ruby
- Stars
- 873
- Forks
- 164
- Avg merge
- 4d 27m
- Merged PRs (30d)
- 9
Description
Motivation
In Tapioca, we've always defaulted to generating reader/writer methods instead of
attr_xxxdeclarations, because it is harder to figure out if a reader/writer method was defined via anattr_xxxcall, but also because if Tapioca generatedattr_xxxdeclarations, Sorbet would then do more work to turn them into reader/writer method definitions in its rewriter anyway.Basically, you don't get any advantage from using
attr_xxxdeclarations in RBIs, you actually get slightly worse performance because of the extra rewriter phases that need to happen.As a result, I think we should:
Merge
attr_xxxdeclarations with the corresponding reader/writer method definitions, ANDAlways leave method definitions behind.
Originally posted by @paracycle in #1709
Steps
### Tasks
- [ ] https://github.com/Shopify/rbi/pull/308
- [ ] Modify Tapioca to run the rewriter when reading user-generated RBIs
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.