Skip to content

Commit

Permalink
Reserve singleton_method_added from Java binding
Browse files Browse the repository at this point in the history
If bound from a Java method, it almost certainly will have the
wrong signature for Ruby calls to it, leading to arity and other
errors when a singleton method or class method are defined on a
Java proxy type.
  • Loading branch information
headius committed Jan 19, 2024
1 parent c498a46 commit aabeb50
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ public class MethodGatherer {
static {
STATIC_RESERVED_NAMES = newReservedNamesMap(1);
STATIC_RESERVED_NAMES.put("new", new AssignedName("new", Priority.RESERVED));
// "singleton_method_added" gets called on the metaclass for metaclass method definitions
STATIC_RESERVED_NAMES.put("singleton_method_added", new AssignedName("singleton_method_added", Priority.RESERVED));
}

static {
Expand All @@ -82,6 +84,8 @@ public class MethodGatherer {
INSTANCE_RESERVED_NAMES.put("initialize", new AssignedName("initialize", Priority.RESERVED));
// "equal?" should not be overridden (GH-5990)
INSTANCE_RESERVED_NAMES.put("equal?", new AssignedName("equal?", Priority.RESERVED));
// "singleton_method_added" gets called on the object for singleton method definitions
INSTANCE_RESERVED_NAMES.put("singleton_method_added", new AssignedName("singleton_method_added", Priority.RESERVED));
}

// TODO: other reserved names?
Expand Down

0 comments on commit aabeb50

Please sign in to comment.