зеркало из https://github.com/github/ruby.git
[ruby/rdoc] Singleton method visibility should be isolated
Each singleton method definition of the form `def recv.method` has visibility separate from the outer scope and is set to `public` by default. https://github.com/ruby/rdoc/commit/810913a7ea
This commit is contained in:
Родитель
83c98ead4e
Коммит
2325b72cf3
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Загрузка…
Ссылка в новой задаче