Project

General

Profile

Actions

Feature #18270

closed

Refinement#{extend_object,append_features,prepend_features} should be removed

Added by shugo (Shugo Maeda) over 2 years ago. Updated about 2 years ago.

Status:
Closed
Target version:
-
[ruby-core:105805]

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 issues 1 (0 open1 closed)

Related to Ruby master - Bug #17429: Prohibit include/prepend in refinement modulesClosedshugo (Shugo Maeda)Actions
Actions #1

Updated by shugo (Shugo Maeda) over 2 years ago

  • Related to Bug #17429: Prohibit include/prepend in refinement modules added
Actions #2

Updated by jeremyevans0 (Jeremy Evans) over 2 years ago

  • Tracker changed from Bug to Feature
  • Backport deleted (2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN)

Updated by shugo (Shugo Maeda) over 2 years ago

These methods raise ArgumentError since #13236 was fixed, so it may not be necessary to remove them.

Updated by shugo (Shugo Maeda) over 2 years ago

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) over 2 years ago

  • 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) over 2 years ago

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) over 2 years ago

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) about 2 years ago

I've submitted a pull request to implement this: https://github.com/ruby/ruby/pull/5358

Updated by shugo (Shugo Maeda) about 2 years ago

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?

Actions #10

Updated by jeremyevans (Jeremy Evans) about 2 years ago

  • 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]

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0