Project

General

Profile

Feature #8035

singleton class should be included in ancestors

Added by marcandre (Marc-Andre Lafortune) over 6 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Normal
Target version:
[ruby-core:53171]

Description

I feel it would be consistent if:

k.ancestors.include?(k) #=> always true if k.is_a?(Class)

This is currently the case except for singleton classes:

class << ""; include Enumerable; end.ancestors
# => [Enumerable, String, Comparable, Object, Kernel, BasicObject]
# would be more consistent:
# => [#<Class:#<String:0x0000010113d268>>, Enumerable, String, Comparable, Object, Kernel, BasicObject]

Note that the singleton classes do appear in the ancestors if a module is instead prepended:

class << ""; prepend Enumerable; end.ancestors
# => [Enumerable, #<Class:#<String:0x0000010113d268>>, String, Comparable, Object, Kernel, BasicObject]

Thanks


Related issues

Related to Ruby master - Bug #8166: Since r39628 rspec-mock's and_call_original fail with SystemStackErrorRejected03/27/2013Actions

Associated revisions

Revision dfde34cb
Added by marcandre (Marc-Andre Lafortune) over 6 years ago

  • class.c (rb_mod_ancestors): Include singleton_class in ancestors list
    [Feature #8035]

  • test/ruby/test_module.rb (class): test for above

  • test/ruby/marshaltestlib.rb (module): adapt test

  • NEWS: list change

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39628 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 39628
Added by marcandre (Marc-Andre Lafortune) over 6 years ago

  • class.c (rb_mod_ancestors): Include singleton_class in ancestors list
    [Feature #8035]

  • test/ruby/test_module.rb (class): test for above

  • test/ruby/marshaltestlib.rb (module): adapt test

  • NEWS: list change

Revision 39628
Added by marcandre (Marc-Andre Lafortune) over 6 years ago

  • class.c (rb_mod_ancestors): Include singleton_class in ancestors list
    [Feature #8035]

  • test/ruby/test_module.rb (class): test for above

  • test/ruby/marshaltestlib.rb (module): adapt test

  • NEWS: list change

Revision 39628
Added by marcandre (Marc-Andre Lafortune) over 6 years ago

  • class.c (rb_mod_ancestors): Include singleton_class in ancestors list
    [Feature #8035]

  • test/ruby/test_module.rb (class): test for above

  • test/ruby/marshaltestlib.rb (module): adapt test

  • NEWS: list change

Revision 39628
Added by marcandre (Marc-Andre Lafortune) over 6 years ago

  • class.c (rb_mod_ancestors): Include singleton_class in ancestors list
    [Feature #8035]

  • test/ruby/test_module.rb (class): test for above

  • test/ruby/marshaltestlib.rb (module): adapt test

  • NEWS: list change

Revision 39628
Added by marcandre (Marc-Andre Lafortune) over 6 years ago

  • class.c (rb_mod_ancestors): Include singleton_class in ancestors list
    [Feature #8035]

  • test/ruby/test_module.rb (class): test for above

  • test/ruby/marshaltestlib.rb (module): adapt test

  • NEWS: list change

Revision 39628
Added by marcandre (Marc-Andre Lafortune) over 6 years ago

  • class.c (rb_mod_ancestors): Include singleton_class in ancestors list
    [Feature #8035]

  • test/ruby/test_module.rb (class): test for above

  • test/ruby/marshaltestlib.rb (module): adapt test

  • NEWS: list change

Revision 246102b5
Added by marcandre (Marc-Andre Lafortune) over 6 years ago

  • NEWS: Be more precise about singleton_class.ancestors change [Feature #8035]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40004 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 40004
Added by marcandre (Marc-Andre Lafortune) over 6 years ago

  • NEWS: Be more precise about singleton_class.ancestors change [Feature #8035]

Revision 40004
Added by marcandre (Marc-Andre Lafortune) over 6 years ago

  • NEWS: Be more precise about singleton_class.ancestors change [Feature #8035]

Revision 40004
Added by marcandre (Marc-Andre Lafortune) over 6 years ago

  • NEWS: Be more precise about singleton_class.ancestors change [Feature #8035]

Revision 40004
Added by marcandre (Marc-Andre Lafortune) over 6 years ago

  • NEWS: Be more precise about singleton_class.ancestors change [Feature #8035]

Revision 40004
Added by marcandre (Marc-Andre Lafortune) over 6 years ago

  • NEWS: Be more precise about singleton_class.ancestors change [Feature #8035]

Revision 40004
Added by marcandre (Marc-Andre Lafortune) over 6 years ago

  • NEWS: Be more precise about singleton_class.ancestors change [Feature #8035]

History

Updated by alexeymuranov (Alexey Muranov) over 6 years ago

Singleton class it the same thing as metaclass, right? I feel it would be better to keep it invisible, and maybe in the future to remove it completely and to allow objects to keep their singleton methods themselves.

Updated by matz (Yukihiro Matsumoto) over 6 years ago

Agreed. I will accept it unless any other compatibility problem raises.

Matz.

#3

Updated by marcandre (Marc-Andre Lafortune) over 6 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r39628.
Marc-Andre, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • class.c (rb_mod_ancestors): Include singleton_class in ancestors list
    [Feature #8035]

  • test/ruby/test_module.rb (class): test for above

  • test/ruby/marshaltestlib.rb (module): adapt test

  • NEWS: list change

Also available in: Atom PDF