diff --git a/lib/rdoc/parser/ruby.rb b/lib/rdoc/parser/ruby.rb index 39c3bae4c4..aab91e0790 100644 --- a/lib/rdoc/parser/ruby.rb +++ b/lib/rdoc/parser/ruby.rb @@ -1453,6 +1453,12 @@ class RDoc::Parser::Ruby < RDoc::Parser meth = RDoc::AnyMethod.new get_tkread, name look_for_directives_in meth, comment meth.singleton = single == SINGLE ? true : singleton + if singleton + # `current_line_visibility' is useless because it works against + # the normal method named as same as the singleton method, after + # the latter was defined. Of course these are different things. + container.current_line_visibility = :public + end record_location meth meth.line = line_no diff --git a/test/rdoc/test_rdoc_context.rb b/test/rdoc/test_rdoc_context.rb index 85665599fb..ac425349d8 100644 --- a/test/rdoc/test_rdoc_context.rb +++ b/test/rdoc/test_rdoc_context.rb @@ -927,6 +927,8 @@ class TestRDocContext < XrefTestCase assert_equal :private, @c6.find_method_named('priv6').visibility assert_equal :protected, @c6.find_method_named('prot6').visibility assert_equal :public, @c6.find_method_named('pub6').visibility + assert_equal :public, @c6.find_method_named('s_pub1').visibility + assert_equal :public, @c6.find_method_named('s_pub3').visibility end def util_visibilities diff --git a/test/rdoc/xref_data.rb b/test/rdoc/xref_data.rb index c9315b7806..42b5d1baf3 100644 --- a/test/rdoc/xref_data.rb +++ b/test/rdoc/xref_data.rb @@ -74,6 +74,7 @@ class C6 def priv4() end public def pub5() end def priv5() end + def self.s_pub1() end protected private def priv6() end @@ -82,6 +83,7 @@ class C6 def prot5() end public def pub6() end def prot6() end + def self.s_pub3() end end class C7