Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Adapt JRuby arity workaround to BlockSignature #347

Merged
merged 1 commit into from
Mar 14, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib/rspec/support/method_signature_verifier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,19 @@ def classify_parameters
# aliases to make method names look more Rubyesque). If there is only a
# single match, we can use that methods arity directly instead of the
# default -1 arity.
#
# This workaround only works for Java proxy methods, and in order to
# support regular methods and blocks, we need to be careful about calling
# owner and java_class as they might not be available
if Java::JavaLang::String.instance_method(:char_at).arity == -1
class MethodSignature < remove_const(:MethodSignature)
private

def classify_parameters
super
return unless @method.arity == -1 && @method.owner.respond_to?(:java_class)
return unless @method.arity == -1
return unless @method.respond_to?(:owner)
return unless @method.owner.respond_to?(:java_class)
java_instance_methods = @method.owner.java_class.java_instance_methods
compatible_overloads = java_instance_methods.select do |java_method|
@method == @method.owner.instance_method(java_method.name)
Expand Down