Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/rbs/definition_builder/ancestor_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ def singleton_ancestors(type_name, building_ancestors: [])
when Definition::Ancestor::Singleton
super_name = super_class.name

super_ancestors = singleton_ancestors(super_name, building_ancestors: [])
super_ancestors = singleton_ancestors(super_name, building_ancestors: building_ancestors)
ancestors.unshift(*super_ancestors.ancestors)
end

Expand Down
19 changes: 19 additions & 0 deletions test/rbs/ancestor_builder_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,25 @@ module Y[A]
end
end

def test_singleton_ancestors_recursive_superclass
SignatureManager.new do |manager|
manager.files[Pathname("foo.rbs")] = <<EOF
class A < B
end

class B < A
end
EOF
manager.build do |env|
builder = DefinitionBuilder::AncestorBuilder.new(env: env)

assert_raises(RecursiveAncestorError) do
builder.singleton_ancestors(type_name("::A"))
end
end
end
end

def test_build_invalid_type_application
SignatureManager.new do |manager|
manager.files[Pathname("foo.rbs")] = <<EOF
Expand Down
Loading