Skip to content

Commit 0bff787

Browse files
committed
Check and set appropriate method's aliased flag
The exact old method should be marked as aliased, so if re-aliased back again it won't trigger a warning. See jruby#9447
1 parent 1f90e36 commit 0bff787

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

core/src/main/java/org/jruby/RubyModule.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5625,7 +5625,7 @@ public synchronized <T extends RubyModule> T defineAlias(ThreadContext context,
56255625

56265626
DynamicMethod method = getMethods().get(name);
56275627
if (method != null && entry.method.getRealMethod() != method.getRealMethod() && !method.isUndefined()) {
5628-
if (!method.getRealMethod().isAliased()) {
5628+
if (!entry.method.isAliased()) {
56295629
if (method instanceof PositionAware posAware) {
56305630
warning(context, "method redefined; discarding old " + name + "\n" + posAware.getFile() + ":" + (posAware.getLine() + 1) + ": warning: previous definition of " + name + " was here");
56315631
} else {

core/src/main/java/org/jruby/internal/runtime/methods/AliasMethod.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public class AliasMethod extends DynamicMethod {
6868
*/
6969
public AliasMethod(RubyModule implementationClass, CacheEntry entry, String newName, String oldName) {
7070
super(implementationClass, determineVisibility(newName, entry.method.getVisibility()), oldName);
71-
entry.method.getRealMethod().setAliased();
71+
entry.method.setAliased();
7272

7373
this.entry = entry;
7474

0 commit comments

Comments
 (0)