Skip to content

Commit

Permalink
Don't report arity problems for unresolvable delegated methods
Browse files Browse the repository at this point in the history
  • Loading branch information
grncdr committed May 7, 2023
1 parent 69a0a71 commit 145618b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/solargraph/pin/delegated_method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ def initialize(method: nil, receiver: nil, name: method&.name, receiver_method_n
end
end

def resolvable?(api_map)
resolve_method(api_map)
!!@resolved_method
end

private

# Resolves the receiver chain and method name to a method pin, resetting any previously resolution.
Expand Down
5 changes: 4 additions & 1 deletion lib/solargraph/type_checker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,10 @@ def argument_problems_for chain, api_map, block_pin, locals, location
base = chain
until base.links.length == 1 && base.undefined?
pins = base.define(api_map, block_pin, locals)
if pins.first.is_a?(Pin::Method)

if pins.first.is_a?(Pin::DelegatedMethod) && !pins.first.resolvable?(api_map)
# Do nothing, as we can't find the actual method implementation
elsif pins.first.is_a?(Pin::Method)
# @type [Pin::Method]
pin = pins.first
ap = if base.links.last.is_a?(Solargraph::Source::Chain::ZSuper)
Expand Down

0 comments on commit 145618b

Please sign in to comment.