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

Conversation

grddev
Copy link
Contributor

@grddev grddev commented Mar 12, 2018

The workaround looking up the corresponding Java class and looking at its methods only works for methods, and doesn't work for Proc, where there isn't a direct API to access the proxied Java class.

While the same problem exists for Proc's, until jruby/jruby#2817 has been resolved, there isn't much that can be done for that case. However, the current code fails to run for all blocks with arity -1, so this tweak is necessary to ensure normal blocks work again.

I couldn't find any specs for BlockSignature, so wasn't sure where it would be appropriate to add a test for this.

@@ -186,7 +186,7 @@ class MethodSignature < remove_const(:MethodSignature)

def classify_parameters
super
return unless @method.arity == -1 && @method.owner.respond_to?(:java_class)
return unless @method.arity == -1 && @method.respond_to?(:owner) && @method.owner.respond_to?(:java_class)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than specs then, can we get a note about why this is necessary?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line needs to be broken up to pass the build now :)

The workaround looking up the corresponding Java class and looking at its methods only works for methods, and doesn't work for Proc, where there isn't a direct API to access the proxied Java class.

While the same problem exists for Proc's, until jruby/jruby#2817 has been resolved, there isn't much that can be done for that case. However, the current code fails to run for all blocks with arity -1, so this tweak is necessary to ensure normal blocks work again.

I couldn't find any specs for BlockSignature, so wasn't sure where it would be appropriate to add a test for this.
@grddev grddev force-pushed the adapt-jruby-workaround-to-blocks branch from ffcae07 to 07be559 Compare March 12, 2018 09:44
@myronmarston myronmarston merged commit 3a203f5 into rspec:master Mar 14, 2018
@myronmarston
Copy link
Member

Thanks @grddev!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants