Feature #18270
closedRefinement#{extend_object,append_features,prepend_features} should be removed
Added by shugo (Shugo Maeda) about 4 years ago. Updated almost 4 years ago.
Description
Refinement#{extend_object,append_features,prepend_features} are not useful and should be removed.
How about to deprecate them in Ruby 3.1 and remove in Ruby 3.1?
        
          
          Updated by shugo (Shugo Maeda) about 4 years ago
          
          
        
        
          
            Actions
          
          #1
        
      
      - Related to Bug #17429: Prohibit include/prepend in refinement modules added
 
        
          
          Updated by jeremyevans0 (Jeremy Evans) about 4 years ago
          
          
        
        
          
            Actions
          
          #2
        
      
      - Tracker changed from Bug to Feature
 - Backport deleted (
2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN) 
        
          
          Updated by shugo (Shugo Maeda) almost 4 years ago
          
          
        
        
          
            Actions
          
          #3
            [ruby-core:106106]
        
      
      These methods raise ArgumentError since #13236 was fixed, so it may not be necessary to remove them.
        
          
          Updated by shugo (Shugo Maeda) almost 4 years ago
          
          
        
        
          
            Actions
          
          #4
            [ruby-core:106107]
        
      
      append_features is undefined in the class Class, and Module#include raises TypeError before calling append_features if the given argument is a Class.
        
          
          Updated by shugo (Shugo Maeda) almost 4 years ago
          
          
        
        
          
            Actions
          
          #5
            [ruby-core:106117]
        
      
      - Assignee changed from matz (Yukihiro Matsumoto) to shugo (Shugo Maeda)
 
At the developers meeting on 2011-11-18, Matz accepted the following changes in Ruby 3.2:
- Undefine extend_object, append_features, prepend_features in Refinement.
 - extend, include, and prepend raise a TypeError if the given argument is a Refinement as in the case the argument is a Class.
 
No warnings will be added in Ruby 3.1, because append_features etc. currently already raises ArgumentError.
excelsior:ruby$ ruby -e 'class Foo; end; module Bar; refine Integer do append_features(Foo); end; end'
-e:1:in `append_features': refinement module is not allowed (ArgumentError)
        from -e:1:in `block in <module:Bar>'
        from -e:1:in `refine'
        from -e:1:in `<module:Bar>'
        from -e:1:in `<main>'
        
          
          Updated by Eregon (Benoit Daloze) almost 4 years ago
          
          
        
        
          
            Actions
          
          #6
            [ruby-core:106131]
        
      
      Sounds good.
Could you please add tests in ruby/spec to track those changes, under core/refinement?
The structure can be generated with ../mspec/bin/mkspec -b core -c Refinement.
        
          
          Updated by shugo (Shugo Maeda) almost 4 years ago
          
          
        
        
          
            Actions
          
          #7
            [ruby-core:106165]
        
      
      Eregon (Benoit Daloze) wrote in #note-6:
Sounds good.
Thanks.
Could you please add tests in ruby/spec to track those changes, under
core/refinement?
The structure can be generated with../mspec/bin/mkspec -b core -c Refinement.
OK, I'll add tests after implementing these changes after the release of Ruby 3.1.
        
          
          Updated by jeremyevans0 (Jeremy Evans) almost 4 years ago
          
          
        
        
          
            Actions
          
          #8
            [ruby-core:106844]
        
      
      I've submitted a pull request to implement this: https://github.com/ruby/ruby/pull/5358
        
          
          Updated by shugo (Shugo Maeda) almost 4 years ago
          
          
        
        
          
            Actions
          
          #9
            [ruby-core:106971]
        
      
      jeremyevans0 (Jeremy Evans) wrote in #note-8:
I've submitted a pull request to implement this: https://github.com/ruby/ruby/pull/5358
Thank you.  I've approved it, but it has conflicts with my commits....
Could you merge it resolving conflicts?
        
          
          Updated by jeremyevans (Jeremy Evans) almost 4 years ago
          
          
        
        
          
            Actions
          
          #10
        
      
      - Status changed from Assigned to Closed
 
Applied in changeset git|791343b5bb1b8bb11de4ba2800118c20e36b5a71.
Remove Refinement#{extend_object,append_features,prepend_features}
Also make include, prepend, and extend raise a TypeError if one
of the modules is a refinement.
Implements [Feature #18270]