Skip to content

Commit

Permalink
Merge pull request #1197 from soutaro/fcall
Browse files Browse the repository at this point in the history
Fix shape calculation error
  • Loading branch information
soutaro authored Aug 1, 2024
2 parents 7c5ff82 + f574b04 commit 40cd42b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/steep/services/completion_provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -725,14 +725,15 @@ def instance_variable_items_for_context(context, position:, prefix:, items:)
end

def keyword_argument_items_for_method(call_node:, send_node:, position:, prefix:, items:)
receiver_node, method_name, argument_nodes = deconstruct_send_node!(send_node)
_receiver_node, _method_name, argument_nodes = deconstruct_send_node!(send_node)

call = typing.call_of(node: call_node)

case call
when TypeInference::MethodCall::Typed, TypeInference::MethodCall::Error
context = typing.context_at(line: position.line, column: position.column)
type = call.receiver_type
type = type.subst(Interface::Substitution.build([], self_type: context.self_type, module_type: context.module_context&.module_type, instance_type: context.module_context&.instance_type))

config = Interface::Builder::Config.new(self_type: type, variable_bounds: context.variable_context.upper_bounds)
if shape = subtyping.builder.shape(type, config)
Expand Down
11 changes: 11 additions & 0 deletions test/completion_provider_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -650,4 +650,15 @@ def test_comment__type
end
end
end

def test_self_receiver_call_type
with_checker do
CompletionProvider.new(source_text: <<-EOR, path: Pathname("foo.rb"), subtyping: checker).tap do |provider|
puts i
EOR

provider.run(line: 1, column: 6) # Assert nothing raised
end
end
end
end

0 comments on commit 40cd42b

Please sign in to comment.