Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling Kernel method in a subclass of SimpleDelegator fails with TypeError: bind argument must be an instance of Kernel #2463

Closed
jirutka opened this issue Jan 15, 2015 · 3 comments

Comments

@jirutka
Copy link

jirutka commented Jan 15, 2015

Minimal working example:

require 'delegate'

class MyDelegator < SimpleDelegator

  def initialize
    super String
  end

  def warn_me
    warn 'FIRE!'
  end
end

MyDelegator.new.warn_me

Expected output:

FIRE!

Tested on MRI 1.9.3, 2.1.2 and 2.2.0.

Actual output on jruby-9000-dev:

TypeError: bind argument must be an instance of Kernel
            bind at org/jruby/RubyUnboundMethod.java:105
  method_missing at /Users/jimmy/.rbenv/versions/jruby-9000-dev/lib/ruby/stdlib/delegate.rb:89
       warn_me_3 at delegator.rb:10
      __script__ at delegator.rb:14

Tested on:

jruby 9.0.0.0-SNAPSHOT (2.2.0p0) 2015-01-15 4142c8d Java HotSpot(TM) 64-Bit Server VM 25.0-b70 on 1.8.0-b132 +jit [darwin-x86_64]

Workaround:

require 'delegate'

class SimpleDelegator
  def warn(*msg)
    Kernel.warn(*msg)
  end
end
@headius
Copy link
Member

headius commented Jan 15, 2015

Confirmed...seems like our logic for binding an unbound method is not detecting Kernel in hierarchy.

@headius
Copy link
Member

headius commented Jan 15, 2015

Ahh right...UnboundMethod was changed recently to allow module methods to be bound to any object. Fixing.

headius added a commit that referenced this issue Jan 15, 2015
@headius headius added this to the JRuby 9.0.0.0-pre1 milestone Jan 15, 2015
@headius headius self-assigned this Jan 15, 2015
@jirutka
Copy link
Author

jirutka commented Jan 18, 2015

Great, it works now. Thanks!

jirutka added a commit to asciidoctor/asciidoctor-doctest that referenced this issue Jan 18, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants