Feature #18270
closed
Refinement#{extend_object,append_features,prepend_features} should be removed
Added by shugo (Shugo Maeda) about 3 years ago.
Updated almost 3 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?
- Related to Bug #17429: Prohibit include/prepend in refinement modules added
- Tracker changed from Bug to Feature
- Backport deleted (
2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN)
These methods raise ArgumentError since #13236 was fixed, so it may not be necessary to remove them.
append_features is undefined in the class Class, and Module#include raises TypeError before calling append_features if the given argument is a Class.
- 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>'
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
.
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.
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?
- 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]
Also available in: Atom
PDF
Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0