Improve alias redefinition warnings#9447
Merged
Merged
Conversation
Make these a single warning call to be a single write as in CRuby.
headius
added a commit
to headius/jruby
that referenced
this pull request
May 20, 2026
The exact old method should be marked as aliased, so if re-aliased back again it won't trigger a warning. See jruby#9447
This is CRuby behavior and Rails uses it as a hack for reverse- aliasing methods without warnings. See rails/rails#29233
headius
force-pushed
the
alias_redefinition_fixes
branch
from
May 20, 2026 06:55
0bff787 to
f7352f0
Compare
Previous patch incorrectly checked the source method. This should be squashed into that commit.
Member
Author
|
Example case: class Foo
def foo end
alias_method :bar, :foo
define_method(:foo) {}
alias_method :foo, :foo
alias_method :foo, :bar
endThe self-aliasing here adds an alias bit to the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
These warnings are firing a lot in Rails when they should not. The key piece is setting the aliased method's aliased bit so aliasing back doesn't warn, based on the hack in rails/rails#29233. This PR makes tweaks to handle that case and clean up related code.