Issue #10765 has been updated by Shugo Maeda.

Status changed from Open to Assigned
Assignee set to Shugo Maeda

----------------------------------------
Bug #10765: Module#remove_method remove refined method entry.
https://bugs.ruby-lang.org/issues/10765#change-51353

* Author: Seiei Higa
* Status: Assigned
* Priority: Normal
* Assignee: Shugo Maeda
* ruby -v: ruby 2.3.0dev (2015-01-21 trunk 49326) [x86_64-darwin14]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
`Module#remove_method` should raise a `NameError`
if method is not defined in refined class, such as [`undef`](https://bugs.ruby-lang.org/issues/8966).
But if method is defined in refined class, `Module#remove_method` should keep refined method and remove original method.

I confirmed by following examples in ruby-trunk, 2.2.0, 2.1.5, 2.0.0-p598

``` ruby
class C
  def foo
    "C#foo"
  end
end

module RefinementBug
  refine C do
    def foo
      "RefinementBug#foo"
    end
  end
end

using RefinementBug

class C
  remove_method :foo
end

puts C.new.foo

# expected:
#   RefinementBug#foo
#
# actual:
#   bug.rb:21:in `<main>': undefined method `foo' for #<C:0x007f9e5c087b48> (NoMethodError)
```

``` ruby
class C
end

module RefinementBug
  refine C do
    def foo
    end
  end
end

using RefinementBug

class C
  remove_method :foo
end

# expected:
#   bug2.rb:14:in `remove_method': method `foo' not defined in C (NameError)
#   from bug2.rb:14:in `<class:C>'
#   from bug2.rb:13:in `<main>'
#
# actual:
#   # => nothing raised.
```

---Files--------------------------------
bug2.rb (327 Bytes)
bug.rb (342 Bytes)
0001-vm_method.c-fix-remove-refined-method.patch (2.68 KB)


-- 
https://bugs.ruby-lang.org/