Skip to content

Calling Kernel method in a subclass of SimpleDelegator fails with NoMethodError private method #2412

@jirutka

Description

@jirutka

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions