diff options
author | Koichi Sasada <ko1@atdot.net> | 2022-12-03 05:55:33 +0900 |
---|---|---|
committer | Koichi Sasada <ko1@atdot.net> | 2022-12-03 08:53:12 +0900 |
commit | 59e389af2893c0fcf8b2cfa008c9a16825bf56ff (patch) | |
tree | 31224e3498843912e2fc8734710e03224aaca21c /spec/ruby/core/module | |
parent | 7161bf34e161979b97dbc0c1f7450c195faffcfe (diff) |
UnboundMethod only refer defined_class
UnboundMethod records caller's class, like `D` or `E` on the
following case:
```ruby
class C
def foo = :foo
end
class D < C
end
class E < C
end
d = D.instance_method(:foo)
e = E.instance_method(:foo)
```
But `d` and `e` only refers `C#foo` so that UnboundMethod doesn't
record `D` or `E`. This behavior changes the following methods:
* `UnboundMethod#inspect` (doesn't show caller's class)
* `UnboundMethod#==` (`d == e` for example)
fix https://bugs.ruby-lang.org/issues/18798
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/6855
Diffstat (limited to 'spec/ruby/core/module')
-rw-r--r-- | spec/ruby/core/module/instance_method_spec.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/spec/ruby/core/module/instance_method_spec.rb b/spec/ruby/core/module/instance_method_spec.rb index 30e27bb180..8d006e647e 100644 --- a/spec/ruby/core/module/instance_method_spec.rb +++ b/spec/ruby/core/module/instance_method_spec.rb @@ -45,10 +45,14 @@ describe "Module#instance_method" do @parent_um.inspect.should =~ /\bModuleSpecs::InstanceMeth\b/ @child_um.inspect.should =~ /\bfoo\b/ @child_um.inspect.should =~ /\bModuleSpecs::InstanceMeth\b/ - @child_um.inspect.should =~ /\bModuleSpecs::InstanceMethChild\b/ + @mod_um.inspect.should =~ /\bbar\b/ @mod_um.inspect.should =~ /\bModuleSpecs::InstanceMethMod\b/ - @mod_um.inspect.should =~ /\bModuleSpecs::InstanceMethChild\b/ + + ruby_version_is ""..."3.2" do + @child_um.inspect.should =~ /\bModuleSpecs::InstanceMethChild\b/ + @mod_um.inspect.should =~ /\bModuleSpecs::InstanceMethChild\b/ + end end it "raises a TypeError if the given name is not a String/Symbol" do |