Skip to content

Commit

Permalink
Merge pull request #661 from nobu/bug/unknown-class-at-dynamic-singleton
Browse files Browse the repository at this point in the history
Ignore dynamically added methods
  • Loading branch information
aycabta authored Oct 30, 2018
2 parents 3f1cd4d + 1ce2ccc commit 4be0a09
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/rdoc/parser/c.rb
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ def @enclosure_dependencies.tsort_each_child node, &block
def deduplicate_call_seq
@methods.each do |var_name, functions|
class_name = @known_classes[var_name]
next unless class_name
class_obj = find_class var_name, class_name

functions.each_value do |method_names|
Expand Down
13 changes: 13 additions & 0 deletions test/test_rdoc_parser_c.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1630,6 +1630,19 @@ def test_define_method
assert read_method.singleton
end

def test_define_method_dynamically
content = <<-EOF
void
Init_foo(void)
{
rb_define_singleton_method(obj, "foo", foo, -1);
}
EOF

klass = util_get_class content, 'obj'
assert_nil klass
end

def test_define_method_with_prototype
content = <<-EOF
static VALUE rb_io_s_read(int, VALUE*, VALUE);
Expand Down

0 comments on commit 4be0a09

Please sign in to comment.