This project is closed and read-only.
Bug #2993
closedModule#instance_methods' flag seems to be ignored in singleton classes
Description
=begin
Looks like the flag that tells Module#instance_methods whether to include the ones of superclasses is ignored on singleton classes. For example, in 1.9:
class A
def self.m
end
end
p (class << A; self; end).instance_methods(false)
# => [:m, :allocate, :new, :superclass]
class B < A
end
p (class << B; self; end).instance_methods(false)
# => [:m, :allocate, :new, :superclass]
class C < B
end
p (class << C; self; end).instance_methods(false)
# => [:m, :allocate, :new, :superclass]
I tested this against 1.9.2-head, 1.9.1, and 1.8.7, the string in the "ruby -v" form field below corresponds to the first one.
=end
Updated by fxn (Xavier Noria) over 16 years ago
=begin
I think the problem is that class_instance_method_list in class.c assumes mod is an ordinary mod and thus singleton classes should be always skipped. The for loop has these lines:
See, the recur flag is ignored even if mod was a singleton class in the first place.
=end
Updated by fxn (Xavier Noria) over 16 years ago
=begin
I sent a pull request to shyouhei with what I think is a fix, and tests.
=end
Updated by nobu (Nobuyoshi Nakada) over 16 years ago
=begin
Hi,
At Mon, 22 Mar 2010 04:45:55 +0900,
Xavier Noria wrote in [ruby-core:28843]:
I sent a pull request to shyouhei with what I think is a fix, and tests.
No pull-request please, post the patch reference instead.
Others can't review pull-requests.
--
Nobu Nakada
=end
Updated by fxn (Xavier Noria) over 16 years ago
=begin
Oh sure, is a reference to a single git commit OK?
If you prefer some other way to submit the patch please just tell me :).
As you'll see the patch removes
because AFAICT ordinary and eigenclasses super-chains cannot intersect. I don't see a reason why the foor loop should have that line at all, and it seems to be the reason instance_methods works as reported in this ticket for singleton classes. Is that fix correct?
The patch also includes regression tests.
How do you run the entire test suite in test/ruby?
-- fxn
BTW I followed the instructions here http://wiki.github.com/shyouhei/ruby/noncommitterhowto, coming in turn from http://www.ruby-lang.org/en/community/ruby-core/#git-ruby, in case those need to be updated.
=end
Updated by shyouhei (Shyouhei Urabe) over 16 years ago
- Status changed from Open to Assigned
- Assignee set to nobu (Nobuyoshi Nakada)
=begin
Hi Nobu, How do you feel about the proposed fix?
I can merge it if you are OK.
=end
Updated by nobu (Nobuyoshi Nakada) over 16 years ago
=begin
Hi,
At Mon, 22 Mar 2010 16:42:12 +0900,
Xavier Noria wrote in [ruby-core:28858]:
Oh sure, is a reference to a single git commit OK?
If you prefer some other way to submit the patch please just tell me :).
It seems fine for me.
because AFAICT ordinary and eigenclasses super-chains cannot
intersect. I don't see a reason why the foor loop should have
that line at all, and it seems to be the reason
instance_methods works as reported in this ticket for
singleton classes. Is that fix correct?
Sounds reasonable.
How do you run the entire test suite in test/ruby?
make test-ruby
BTW I followed the instructions here
http://wiki.github.com/shyouhei/ruby/noncommitterhowto,
coming in turn from
http://www.ruby-lang.org/en/community/ruby-core/#git-ruby, in
case those need to be updated.
The page says:
Then send me a pull request. I cannot promise (that depends on
your branch’s content,) but I may perhaps merge your branch to
mine.
"mine" means his repository here. In that case, he might have
to post it here and review it again.
--
Nobu Nakada
=end
Updated by fxn (Xavier Noria) over 16 years ago
=begin
This ticket can be closed, the patch was applied in revision 27085:
http://redmine.ruby-lang.org/repositories/diff/ruby-19?rev=27085
=end
Updated by marcandre (Marc-Andre Lafortune) over 16 years ago
- Status changed from Assigned to Closed
=begin
=end