Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translate RBI attached_class to RBS instance #384

Merged
merged 1 commit into from
Dec 17, 2024
Merged
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/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
Loading