Permalink
Browse files

Merge pull request #707 from atambo/kernel_singleton_methods_uniq

Kernel#singleton_methods should return a unique list of methods
  • Loading branch information...
2 parents 4de60c0 + 2997b7a commit 23d98177301f88f1b49d5ce06bb9042d54e63f98 @headius headius committed 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 {

0 comments on commit 23d9817

Please sign in to comment.