From a9dfb05649875d7edd069fb329021b4dea3397cc Mon Sep 17 00:00:00 2001 From: dak2 <32436625+dak2@users.noreply.github.com> Date: Sun, 25 Oct 2026 18:47:18 +0900 Subject: [PATCH] Fix recursive superclass check in singleton_ancestors The superclass recursion reset building_ancestors, so a cycle raised SystemStackError instead of RecursiveAncestorError. --- .../definition_builder/ancestor_builder.rb | 2 +- test/rbs/ancestor_builder_test.rb | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) 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")] = <