summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-10-28 01:56:28 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-10-28 01:56:28 +0000
commit8586f021f8db193b746079aff7ee50461957f39d (patch)
treef437281a80b7bcf4a6ce2e3ae5a48c7a1481dd93
parent091c04df537425d9e73b8b2f079522a05df93119 (diff)
rdoc/parser/c.rb: ignore dynamically added methods
* 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65403 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--lib/rdoc/parser/c.rb1
-rw-r--r--test/rdoc/test_rdoc_parser_c.rb13
2 files changed, 14 insertions, 0 deletions
diff --git a/lib/rdoc/parser/c.rb b/lib/rdoc/parser/c.rb
index 183538d54b..425ea11f63 100644
--- a/lib/rdoc/parser/c.rb
+++ b/lib/rdoc/parser/c.rb
@@ -217,6 +217,7 @@ class RDoc::Parser::C < RDoc::Parser
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|
diff --git a/test/rdoc/test_rdoc_parser_c.rb b/test/rdoc/test_rdoc_parser_c.rb
index b8bdbca7fd..3d30d767df 100644
--- a/test/rdoc/test_rdoc_parser_c.rb
+++ b/test/rdoc/test_rdoc_parser_c.rb
@@ -1630,6 +1630,19 @@ Init_IO(void) {
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);