[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:
parent
83c98ead4e
commit
2325b72cf3
@ -1453,6 +1453,12 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|||||||
meth = RDoc::AnyMethod.new get_tkread, name
|
meth = RDoc::AnyMethod.new get_tkread, name
|
||||||
look_for_directives_in meth, comment
|
look_for_directives_in meth, comment
|
||||||
meth.singleton = single == SINGLE ? true : singleton
|
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
|
record_location meth
|
||||||
meth.line = line_no
|
meth.line = line_no
|
||||||
|
@ -927,6 +927,8 @@ class TestRDocContext < XrefTestCase
|
|||||||
assert_equal :private, @c6.find_method_named('priv6').visibility
|
assert_equal :private, @c6.find_method_named('priv6').visibility
|
||||||
assert_equal :protected, @c6.find_method_named('prot6').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('pub6').visibility
|
||||||
|
assert_equal :public, @c6.find_method_named('s_pub1').visibility
|
||||||
|
assert_equal :public, @c6.find_method_named('s_pub3').visibility
|
||||||
end
|
end
|
||||||
|
|
||||||
def util_visibilities
|
def util_visibilities
|
||||||
|
@ -74,6 +74,7 @@ class C6
|
|||||||
def priv4() end
|
def priv4() end
|
||||||
public def pub5() end
|
public def pub5() end
|
||||||
def priv5() end
|
def priv5() end
|
||||||
|
def self.s_pub1() end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
private def priv6() end
|
private def priv6() end
|
||||||
@ -82,6 +83,7 @@ class C6
|
|||||||
def prot5() end
|
def prot5() end
|
||||||
public def pub6() end
|
public def pub6() end
|
||||||
def prot6() end
|
def prot6() end
|
||||||
|
def self.s_pub3() end
|
||||||
end
|
end
|
||||||
|
|
||||||
class C7
|
class C7
|
||||||
|
Loading…
x
Reference in New Issue
Block a user