Skip to content

Commit 01d02c8

Browse files
committed
Support instance method returning instance type
1 parent ff75598 commit 01d02c8

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

lib/repl_type_completor/types.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,8 @@ def self.from_rbs_type(return_type, self_type, extra_vars = {})
332332
self_type.transform do |type|
333333
if type.is_a?(SingletonType) && type.module_or_class.is_a?(Class)
334334
InstanceType.new type.module_or_class
335+
elsif type.is_a?(InstanceType)
336+
InstanceType.new type.klass
335337
else
336338
OBJECT
337339
end

test/repl_type_completor/test_type_analyze.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,5 +719,10 @@ def test_rbs_untyped_function
719719
# Proc#call `(?) -> untyped` is RBS::Types::UntypedFunction
720720
assert_call('proc{}.call; 1.', include: Integer)
721721
end
722+
723+
def test_rbs_instance_type
724+
assert_call('Thread.start{}.', include: Thread)
725+
assert_call('"".encode("utf-8").', include: String)
726+
end
722727
end
723728
end

0 commit comments

Comments
 (0)