Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Single warning call for redefinition warning
Make these a single warning call to be a single write as in CRuby.
  • Loading branch information
headius committed May 20, 2026
commit b2443349a513523f2adb2cb11723f81fcfaf5bc5
10 changes: 6 additions & 4 deletions core/src/main/java/org/jruby/RubyModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -5622,10 +5622,12 @@ public synchronized <T extends RubyModule> T defineAlias(ThreadContext context,

DynamicMethod method = getMethods().get(name);
if (method != null && entry.method.getRealMethod() != method.getRealMethod() && !method.isUndefined()) {
if (method.getRealMethod().getAliasCount() == 0) warning(context, "method redefined; discarding old " + name);

if (method instanceof PositionAware posAware) {
context.runtime.getWarnings().warning(ID.REDEFINING_METHOD, posAware.getFile(), posAware.getLine() + 1, "previous definition of " + name + " was here");
if (method.getRealMethod().getAliasCount() == 0) {
if (method instanceof PositionAware posAware) {
warning(context, "method redefined; discarding old " + name + "\n" + posAware.getFile() + ":" + (posAware.getLine() + 1) + ": warning: previous definition of " + name + " was here");
} else {
warning(context, "method redefined; discarding old " + name);
}
}
}

Expand Down