Skip to content

Commit 53c7c7b

Browse files
committed
Support singleton alias
refs: #187
1 parent 73efcc5 commit 53c7c7b

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
@@ -497,10 +497,11 @@ def translate_member(member, decl, rbs)
497497
comment = RBS::AST::Comment.new(string: member.comments.content(trim: true), location: nil)
498498
end
499499

500+
kind = decl ? :singleton : :instance #: RBS::AST::Members::Alias::kind
500501
rbs << RBS::AST::Members::Alias.new(
501502
new_name: member.new_name,
502503
old_name: member.old_name,
503-
kind: :instance,
504+
kind: kind,
504505
annotations: [],
505506
location: nil,
506507
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)