Skip to content

Commit

Permalink
Translate RBI attached_class to RBS instance
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
  • Loading branch information
Morriar committed Dec 10, 2024
1 parent 1be14cf commit 70d9f52
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rbi/rbs_printer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
11 changes: 11 additions & 0 deletions test/rbi/rbs_printer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 70d9f52

Please sign in to comment.