[ruby/rdoc] Fix prism_ruby superclass resolve order

(https://github.com/ruby/rdoc/pull/1267)

RDoc::Parser::PrismRuby wrongly resolves superclass of `class Cipher < Cipher; end` that exist in openssl.
Superclass resolve should be done before adding class.

57a4615a92
This commit is contained in:
tomoya ishida 2025-01-03 20:13:52 +09:00 committed by git
parent fb73be1f2a
commit 23018c2fb4
2 changed files with 23 additions and 2 deletions

View file

@ -201,6 +201,25 @@ module RDocParserPrismTestCases
assert_equal ['A::B', 'A::B', 'A::A::B', 'A::B'], classes.drop(1).map(&:superclass).map(&:full_name)
end
def test_pseudo_recursive_superclass
util_parser <<~RUBY
module Foo
class Bar
class Foo < Bar; end
# This class definition is used in OpenSSL::Cipher::Cipher
class Bar < Bar; end
class Baz < Bar; end
end
end
RUBY
foo_klass = @store.find_class_named 'Foo::Bar::Foo'
bar_klass = @store.find_class_named 'Foo::Bar::Bar'
baz_klass = @store.find_class_named 'Foo::Bar::Baz'
assert_equal 'Foo::Bar', foo_klass.superclass.full_name
assert_equal 'Foo::Bar', bar_klass.superclass.full_name
assert_equal 'Foo::Bar::Bar', baz_klass.superclass.full_name
end
def test_class_module_nodoc
util_parser <<~RUBY
class Foo # :nodoc: