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

Commit 3a203f5

Browse files
authored
Merge pull request #347 from grddev/adapt-jruby-workaround-to-blocks
Adapt JRuby arity workaround to BlockSignature
2 parents 383b4f9 + 07be559 commit 3a203f5

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/rspec/support/method_signature_verifier.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,19 @@ def classify_parameters
180180
# aliases to make method names look more Rubyesque). If there is only a
181181
# single match, we can use that methods arity directly instead of the
182182
# default -1 arity.
183+
#
184+
# This workaround only works for Java proxy methods, and in order to
185+
# support regular methods and blocks, we need to be careful about calling
186+
# owner and java_class as they might not be available
183187
if Java::JavaLang::String.instance_method(:char_at).arity == -1
184188
class MethodSignature < remove_const(:MethodSignature)
185189
private
186190

187191
def classify_parameters
188192
super
189-
return unless @method.arity == -1 && @method.owner.respond_to?(:java_class)
193+
return unless @method.arity == -1
194+
return unless @method.respond_to?(:owner)
195+
return unless @method.owner.respond_to?(:java_class)
190196
java_instance_methods = @method.owner.java_class.java_instance_methods
191197
compatible_overloads = java_instance_methods.select do |java_method|
192198
@method == @method.owner.instance_method(java_method.name)

0 commit comments

Comments
 (0)