Skip to content

Kernel#singleton_methods should return a unique list of methods #707

Merged
merged 1 commit into from May 6, 2013
View
6 spec/tags/1.8/ruby/core/kernel/singleton_methods_tags.txt
@@ -1,6 +0,0 @@
-fails(JRUBY-5660):Kernel#singleton_methods when not passed an argument returns a unique list for an object extended with a module
-fails(JRUBY-5660):Kernel#singleton_methods when not passed an argument returns a unique list for a subclass
-fails(JRUBY-5660):Kernel#singleton_methods when not passed an argument returns a unique list for a subclass including a module
-fails(JRUBY-5660):Kernel#singleton_methods when passed true returns a unique list for an object extended with a module
-fails(JRUBY-5660):Kernel#singleton_methods when passed true returns a unique list for a subclass
-fails(JRUBY-5660):Kernel#singleton_methods when passed true returns a unique list for a subclass including a module
View
6 spec/tags/1.9/ruby/core/kernel/singleton_methods_tags.txt
@@ -1,6 +0,0 @@
-fails(JRUBY-5660):Kernel#singleton_methods when not passed an argument returns a unique list for an object extended with a module
-fails(JRUBY-5660):Kernel#singleton_methods when not passed an argument returns a unique list for a subclass
-fails(JRUBY-5660):Kernel#singleton_methods when not passed an argument returns a unique list for a subclass including a module
-fails(JRUBY-5660):Kernel#singleton_methods when passed true returns a unique list for an object extended with a module
-fails(JRUBY-5660):Kernel#singleton_methods when passed true returns a unique list for a subclass
-fails(JRUBY-5660):Kernel#singleton_methods when passed true returns a unique list for a subclass including a module
View
10 src/org/jruby/RubyBasicObject.java
@@ -2540,10 +2540,9 @@ private RubyArray singletonMethods(ThreadContext context, IRubyObject[] args, Me
all = args[0].isTrue();
}
- RubyArray singletonMethods;
if (getMetaClass().isSingleton()) {
IRubyObject[] methodsArgs = new IRubyObject[]{context.runtime.getFalse()};
- singletonMethods = collect.instanceMethods(getMetaClass(), methodsArgs);
+ RubyArray singletonMethods = collect.instanceMethods(getMetaClass(), methodsArgs);
if (all) {
RubyClass superClass = getMetaClass().getSuperClass();
@@ -2552,11 +2551,12 @@ private RubyArray singletonMethods(ThreadContext context, IRubyObject[] args, Me
superClass = superClass.getSuperClass();
}
}
- } else {
- singletonMethods = context.runtime.newEmptyArray();
+
+ singletonMethods.uniq_bang(context);
+ return singletonMethods;
}
- return singletonMethods;
+ return context.runtime.newEmptyArray();
}
private abstract static class MethodsCollector {
Something went wrong with that request. Please try again.