diff --git a/lib/robe/core_ext.rb b/lib/robe/core_ext.rb index c80fbcb..26ff00b 100644 --- a/lib/robe/core_ext.rb +++ b/lib/robe/core_ext.rb @@ -3,14 +3,6 @@ class Module alias_method :__name__, :name end - if method_defined?(:singleton_class?) - alias_method :__singleton_class__?, :singleton_class? - else - def __singleton_class__? - self != Class && ancestors.first != self - end - end - unless method_defined?(:__singleton_class__) alias_method :__singleton_class__, :singleton_class end diff --git a/lib/robe/sash.rb b/lib/robe/sash.rb index 41bdc2e..2d2df0f 100644 --- a/lib/robe/sash.rb +++ b/lib/robe/sash.rb @@ -50,7 +50,7 @@ def find_method_owner(mod, inst, sym) def method_spec(method) owner, inst = method.owner, nil - if owner.__singleton_class__? + if owner.singleton_class? # FIXME: Use https://docs.ruby-lang.org/en/3.2/Class.html#method-i-attached_object name = owner.to_s[/Class:([A-Z][^\(> ]*)/, 1] # defined in an eigenclass elsif name = name_cache[owner] diff --git a/lib/robe/sash/includes_tracker.rb b/lib/robe/sash/includes_tracker.rb index 1cfac97..2dbb891 100644 --- a/lib/robe/sash/includes_tracker.rb +++ b/lib/robe/sash/includes_tracker.rb @@ -27,7 +27,7 @@ def self.maybe_scan ObjectSpace.each_object(Module) do |cl| next unless cl.respond_to?(:included_modules) - next if cl.__singleton_class__? + next if cl.singleton_class? cl.included_modules.each { |mod| includers[mod] << [cl, true] } sc = cl.__singleton_class__ sc.included_modules.each { |mod| includers[mod] << [cl, nil] } diff --git a/lib/robe/type_space.rb b/lib/robe/type_space.rb index 27c70de..a097fec 100644 --- a/lib/robe/type_space.rb +++ b/lib/robe/type_space.rb @@ -37,10 +37,8 @@ def scan_with(scanner) unless instance singleton_ancestors = obj.singleton_class.ancestors - if RUBY_VERSION >= "2.1.0" - # Ruby 2.1 includes all singletons in the ancestors chain - singleton_ancestors.reject!(&:__singleton_class__?) - end + # Ruby 2.1+ includes all singletons in the ancestors chain + singleton_ancestors.reject!(&:singleton_class?) scanner.scan(singleton_ancestors, true, false) end diff --git a/lib/robe/visor.rb b/lib/robe/visor.rb index 17a1f73..144902e 100644 --- a/lib/robe/visor.rb +++ b/lib/robe/visor.rb @@ -8,7 +8,7 @@ class Visor SearchError = Class.new(StandardError) def each_object(*args) - ObjectSpace.each_object(*args).reject { |m| m.__singleton_class__? } + ObjectSpace.each_object(*args).reject { |m| m.singleton_class? } end # Returns descendants and (modules only) also includers.