From 70d9f52d83b592237ebfccb43ae7b651313c73c7 Mon Sep 17 00:00:00 2001 From: Alexandre Terrasa Date: Tue, 10 Dec 2024 16:01:03 -0500 Subject: [PATCH] Translate RBI `attached_class` to RBS `instance` Signed-off-by: Alexandre Terrasa --- lib/rbi/rbs_printer.rb | 2 +- test/rbi/rbs_printer_test.rb | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/rbi/rbs_printer.rb b/lib/rbi/rbs_printer.rb index 86e386f..4bd3b8c 100644 --- a/lib/rbi/rbs_printer.rb +++ b/lib/rbi/rbs_printer.rb @@ -880,7 +880,7 @@ def visit_self_type(type) sig { params(type: Type::AttachedClass).void } def visit_attached_class(type) - @string << "attached_class" + @string << "instance" end sig { params(type: Type::Nilable).void } diff --git a/test/rbi/rbs_printer_test.rb b/test/rbi/rbs_printer_test.rb index 8cec0bb..4bcbeb2 100644 --- a/test/rbi/rbs_printer_test.rb +++ b/test/rbi/rbs_printer_test.rb @@ -519,6 +519,17 @@ def test_print_sends assert_empty(rbi.rbs_string) end + def test_print_attached_class + rbi = parse_rbi(<<~RBI) + sig { returns(T.attached_class) } + def foo; end + RBI + + assert_equal(<<~RBI, rbi.rbs_string) + def foo: -> instance + RBI + end + def test_print_t_structs rbi = parse_rbi(<<~RBI) class Foo < T::Struct; end