Skip to content

Fix incorrect extend T::Helpers for foreign annotations #750

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

Merged
merged 1 commit into from
Jun 5, 2025

Conversation

KaanOzkan
Copy link
Contributor

@KaanOzkan KaanOzkan commented Jun 4, 2025

Ran into some gems that specify # @private which was causing us to insert extend T::Sig.

Also a small refactor Annotations -> Annotation

@KaanOzkan KaanOzkan force-pushed the ko-at/annotations branch from c73f532 to 67b86a0 Compare June 4, 2025 15:06
@KaanOzkan KaanOzkan changed the title Fix incorrect extend T::Helpers for foreign annotations Fix incorrect extend T::Helpers for foreign annotations Jun 4, 2025
@KaanOzkan KaanOzkan marked this pull request as ready for review June 4, 2025 15:19
@KaanOzkan KaanOzkan requested a review from a team as a code owner June 4, 2025 15:19
lib/spoom/rbs.rb Outdated
Comment on lines 28 to 31
when "@abstract"
true
when "@interface"
true
when "@sealed"
true
when "@final"
true
when /^@requires_ancestor: /
true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can put multiple cases together like:

Suggested change
when "@abstract"
true
when "@interface"
true
when "@sealed"
true
when "@final"
true
when /^@requires_ancestor: /
true
when "@abstract", "@interface", "@sealed", "@final"
true
when /^@requires_ancestor: /
true

Regexp and string matches can be put together too, but I think giving the regexp match its own condition can make it easier to spot.

when "@without_runtime"
true
else
false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as the above.


#: -> Array[Annotation]
def class_annotations
@annotations.select do |annotation|
Copy link
Member

@st0012 st0012 Jun 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth memoizing this value?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean annotations or the resulting array from select?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The resulting array

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Risky if @comments change?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it change if we already started the translation?

Copy link
Collaborator

@Morriar Morriar Jun 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should they: no. Can they?

I'm generally uneasy with memoization based on array attributes because they can change even with an attr_reader and there is no obvious cut point to freeze them.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fair and I'm fine with not memorizing as it doesn't seem to be a performance bottleneck anyway 👍

Co-authored-by: Alexandre Terrasa <583144+Morriar@users.noreply.github.com>
@KaanOzkan KaanOzkan force-pushed the ko-at/annotations branch from 67b86a0 to e2e6370 Compare June 4, 2025 15:55
@Morriar Morriar merged commit 0bd8f65 into main Jun 5, 2025
8 checks passed
@Morriar Morriar deleted the ko-at/annotations branch June 5, 2025 16:21
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 this pull request may close these issues.

3 participants