diff --git a/lib/ruby_indexer/lib/ruby_indexer/rbs_indexer.rb b/lib/ruby_indexer/lib/ruby_indexer/rbs_indexer.rb index 5b845c60f..78d5a7f93 100644 --- a/lib/ruby_indexer/lib/ruby_indexer/rbs_indexer.rb +++ b/lib/ruby_indexer/lib/ruby_indexer/rbs_indexer.rb @@ -139,13 +139,23 @@ def signatures(member) sig { params(overload: RBS::AST::Members::MethodDefinition::Overload).returns(T::Array[Entry::Parameter]) } def process_overload(overload) - function = T.cast(overload.method_type.type, RBS::Types::Function) - parameters = parse_arguments(function) + function = overload.method_type.type - block = overload.method_type.block - parameters << Entry::BlockParameter.anonymous if block&.required + if function.is_a?(RBS::Types::Function) + parameters = parse_arguments(function) - parameters + block = overload.method_type.block + parameters << Entry::BlockParameter.anonymous if block&.required + return parameters + end + + # Untyped functions are a new RBS feature to declare methods that accept any parameters. For our purposes, + # accepting any argument is equivalent to `...` + if defined?(RBS::Types::UntypedFunction) && function.is_a?(RBS::Types::UntypedFunction) + [Entry::ForwardingParameter.new] + else + [] + end end sig { params(function: RBS::Types::Function).returns(T::Array[Entry::Parameter]) } diff --git a/lib/ruby_indexer/test/rbs_indexer_test.rb b/lib/ruby_indexer/test/rbs_indexer_test.rb index 5a42d4fc9..34a652bbc 100644 --- a/lib/ruby_indexer/test/rbs_indexer_test.rb +++ b/lib/ruby_indexer/test/rbs_indexer_test.rb @@ -348,6 +348,14 @@ def test_signature_alias assert_includes(entry.comments, "Returns `true` if any element of `self` meets a given criterion.") end + def test_indexing_untyped_functions + entries = @index.resolve_method("call", "Method") + + parameters = entries.first.signatures.first.parameters + assert_equal(1, parameters.length) + assert_instance_of(Entry::ForwardingParameter, parameters.first) + end + private def parse_rbs_methods(rbs, method_name)