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 NoMethodError private method #2412

Closed
jirutka opened this issue Jan 2, 2015 · 4 comments

Comments

@jirutka
Copy link

jirutka commented Jan 2, 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:

NoMethodError: private method `warn' called for String:MyDelegator
   warn_me_3 at delegator.rb:10
  __script__ at delegator.rb:14

Workaround:

require 'delegate'

class SimpleDelegator
  # https://github.com/jruby/jruby/issues/2412
  def warn(*msg)
    Kernel.warn(*msg)
  end
end
@headius
Copy link
Member

headius commented Jan 6, 2015

Very likely fixed by the move back to pure-Ruby delegate library in #1370.

@headius headius closed this as completed Jan 6, 2015
@jirutka
Copy link
Author

jirutka commented Jan 6, 2015

Thanks, I’ll try it. Do you know how often Travis fetches a new version of jruby-head?

@jirutka
Copy link
Author

jirutka commented Jan 12, 2015

Well, now it raises another error:

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
ruby --version
jruby 9.0.0.0-SNAPSHOT (2.2.0p0) 2015-01-11 0c11cad Java HotSpot(TM) 64-Bit Server VM 25.0-b70 on 1.8.0-b132 +jit [darwin-x86_64]

Should I open another issue for that…?

@jirutka
Copy link
Author

jirutka commented Jan 15, 2015

Reported in #2463.

@enebo enebo added this to the Invalid or Duplicate milestone Jan 30, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants