Skip to content

Commit

Permalink
rdoc/parser/c.rb: ignore dynamically added methods
Browse files Browse the repository at this point in the history
* lib/rdoc/parser/c.rb (RDoc::Parser::C#deduplicate_call_seq):
  skip dynamically added methods at runtime, because the class
  name is unknown and the defined methods are not accessible from
  that class.
  • Loading branch information
nobu committed Oct 29, 2018
1 parent 3f1cd4d commit 1ce2ccc
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 1ce2ccc

Please sign in to comment.