-
Notifications
You must be signed in to change notification settings - Fork 25
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
Conversation
c73f532
to
67b86a0
Compare
extend T::Helpers
for foreign annotations
lib/spoom/rbs.rb
Outdated
when "@abstract" | ||
true | ||
when "@interface" | ||
true | ||
when "@sealed" | ||
true | ||
when "@final" | ||
true | ||
when /^@requires_ancestor: / | ||
true |
There was a problem hiding this comment.
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:
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 |
There was a problem hiding this comment.
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| |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The resulting array
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Risky if @comments
change?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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>
67b86a0
to
e2e6370
Compare
Ran into some gems that specify
# @private
which was causing us to insertextend T::Sig
.Also a small refactor
Annotations -> Annotation