diff --git a/lib/rbs/definition_builder/ancestor_builder.rb b/lib/rbs/definition_builder/ancestor_builder.rb index 7cc2c7543..3e5d0a137 100644 --- a/lib/rbs/definition_builder/ancestor_builder.rb +++ b/lib/rbs/definition_builder/ancestor_builder.rb @@ -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 diff --git a/test/rbs/ancestor_builder_test.rb b/test/rbs/ancestor_builder_test.rb index bbd4d2d61..634f862d0 100644 --- a/test/rbs/ancestor_builder_test.rb +++ b/test/rbs/ancestor_builder_test.rb @@ -729,6 +729,25 @@ module Y[A] end end + def test_singleton_ancestors_recursive_superclass + SignatureManager.new do |manager| + manager.files[Pathname("foo.rbs")] = <