Skip to content

Commit c4a62ac

Browse files
authored
Merge pull request #191 from tk0miya/187/singleton_alias
Support singleton alias
2 parents 5c20ec0 + 53c7c7b commit c4a62ac

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lib/rbs/inline/writer.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,10 +502,11 @@ def translate_member(member, decl, rbs)
502502
comment = RBS::AST::Comment.new(string: member.comments.content(trim: true), location: nil)
503503
end
504504

505+
kind = decl ? :singleton : :instance #: RBS::AST::Members::Alias::kind
505506
rbs << RBS::AST::Members::Alias.new(
506507
new_name: member.new_name,
507508
old_name: member.old_name,
508-
kind: :instance,
509+
kind: kind,
509510
annotations: [],
510511
location: nil,
511512
comment: comment

test/rbs/inline/writer_test.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,11 @@ class Foo
257257
258258
# foo is an alias of bar
259259
alias :foo :bar
260+
261+
class << self
262+
# self.baz is an alias of self.qux
263+
alias baz qux
264+
end
260265
end
261266
RUBY
262267

@@ -266,6 +271,9 @@ class Foo
266271
267272
# foo is an alias of bar
268273
alias foo bar
274+
275+
# self.baz is an alias of self.qux
276+
alias self.baz self.qux
269277
end
270278
RBS
271279
end

0 commit comments

Comments
 (0)