From: alxtskrnk@... Date: 2015-02-24T18:09:00+00:00 Subject: [ruby-core:68289] [Ruby trunk - Bug #10901] [Open] Object#singleton_methods behaves differently depending on whether the singleton_class exists Issue #10901 has been reported by bug hit. ---------------------------------------- Bug #10901: Object#singleton_methods behaves differently depending on whether the singleton_class exists https://bugs.ruby-lang.org/issues/10901 * Author: bug hit * Status: Open * Priority: Normal * Assignee: * ruby -v: ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux] * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN ---------------------------------------- ```ruby class Class1 def self.foo end end c1 = Class1.new instance_eigen = c1.singleton_class p instance_eigen.singleton_methods(false) instance_eigen.singleton_class p instance_eigen.singleton_methods(false) ``` before the eigen exists, singleton_methods returns the methods on the superclass of the non existent eigen after it's created singleton_methods returns [] The existence or non-existence of the eigen is an implementation detail that should not be exposed to the user, conceptually it always exists. So singleton_methods should treat a non existent eigen as an empty eigen, and not look to its superclass -- https://bugs.ruby-lang.org/