From 930a66bd4693b5410b695edcc2689ea7b6367c74 Mon Sep 17 00:00:00 2001 From: Stephen Sugden Date: Mon, 9 Jan 2023 00:05:52 +0100 Subject: [PATCH] Don't report arity problems for unresolvable delegated methods --- lib/solargraph/pin/delegated_method.rb | 5 +++++ lib/solargraph/type_checker.rb | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/solargraph/pin/delegated_method.rb b/lib/solargraph/pin/delegated_method.rb index c60240ddb..25aab0986 100644 --- a/lib/solargraph/pin/delegated_method.rb +++ b/lib/solargraph/pin/delegated_method.rb @@ -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. diff --git a/lib/solargraph/type_checker.rb b/lib/solargraph/type_checker.rb index 2920903fb..29d299b55 100644 --- a/lib/solargraph/type_checker.rb +++ b/lib/solargraph/type_checker.rb @@ -261,7 +261,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)