Project

General

Profile

Actions

Bug #11512

closed

DelegateClass.#public_{instance_}methods are returning difference values.

Added by kachick (Kenichi Kamiya) over 8 years ago. Updated almost 5 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-linux]
[ruby-core:<unknown>]

Description

Is this intended behavior?

A patch is PR#926(https://github.com/ruby/ruby/pull/926)

require 'delegate'

class Parent
  def parent_public; end

  protected

  def parent_protected; end
end

class Child < Parent
end

class DelegatorChild < DelegateClass(Parent)
end

class Parent
  def parent_public_added; end

  protected

  def parent_protected_added; end
end

ignores = Object.public_instance_methods | Delegator.public_instance_methods

p(Child.public_instance_methods - ignores)                 #=> [:parent_public, :parent_public_added]
p(Child.new.public_methods - ignores)                      #=> [:parent_public, :parent_public_added]

p(DelegatorChild.public_instance_methods - ignores)        #=> got: [:parent_public], expected: [:parent_public, :parent_public_added]
p(DelegatorChild.new(Parent.new).public_methods - ignores) #=> got: [:parent_public, :parent_public_added, :parent_protected]], expected: [:parent_public, :parent_public_added]

Files

fix-delegate-class-method-visibility.patch (3.69 KB) fix-delegate-class-method-visibility.patch jeremyevans0 (Jeremy Evans), 05/24/2019 05:00 AM
Actions

Also available in: Atom PDF

Like0
Like0Like0