From: v.ondruch@... Date: 2015-02-04T15:46:27+00:00 Subject: [ruby-core:68007] [ruby-trunk - Bug #10765] Module#remove_method remove refined method entry. Issue #10765 has been updated by Vit Ondruch. Testing with r49495 and it seems to be fixed. Thanks. ---------------------------------------- Bug #10765: Module#remove_method remove refined method entry. https://bugs.ruby-lang.org/issues/10765#change-51397 * Author: Seiei Higa * Status: Closed * Priority: Normal * Assignee: Shugo Maeda * ruby -v: ruby 2.3.0dev (2015-01-21 trunk 49326) [x86_64-darwin14] * Backport: 2.0.0: REQUIRED, 2.1: REQUIRED, 2.2: REQUIRED ---------------------------------------- `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 `
': undefined method `foo' for # (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 `' # from bug2.rb:13:in `
' # # 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/