Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite attr_reader and friends into def methods #1918

Open
1 of 2 tasks
amomchilov opened this issue Jun 10, 2024 · 0 comments · May be fixed by #1936
Open
1 of 2 tasks

Rewrite attr_reader and friends into def methods #1918

amomchilov opened this issue Jun 10, 2024 · 0 comments · May be fixed by #1936
Assignees

Comments

@amomchilov
Copy link
Contributor

amomchilov commented Jun 10, 2024

Motivation

In Tapioca, we've always defaulted to generating reader/writer methods instead of attr_xxx declarations, because it is harder to figure out if a reader/writer method was defined via an attr_xxx call, but also because if Tapioca generated attr_xxx declarations, 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_xxx declarations 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:

  1. Merge attr_xxx declarations with the corresponding reader/writer method definitions, AND

  2. Always leave method definitions behind.

Originally posted by @paracycle in #1709

Steps

Tasks

Preview Give feedback
  1. feature
    amomchilov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant