Skip to content

UnboundMethod only refer defined_class - #6855

Merged
ko1 merged 1 commit into
ruby:masterfrom
ko1:unbound_method_class
Dec 2, 2022
Merged

UnboundMethod only refer defined_class#6855
ko1 merged 1 commit into
ruby:masterfrom
ko1:unbound_method_class

Conversation

@ko1

@ko1 ko1 commented Dec 2, 2022

Copy link
Copy Markdown
Contributor

UnboundMethod records caller's class, like D or E on the following case:

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

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
@ko1
ko1 force-pushed the unbound_method_class branch from cb03464 to f2d3530 Compare December 2, 2022 21:13
@ko1
ko1 marked this pull request as ready for review December 2, 2022 21:14
@ko1
ko1 merged commit 59e389a into ruby:master Dec 2, 2022
rwstauner added a commit to Shopify/truffleruby that referenced this pull request Feb 2, 2024
We're only concerned with where the method was declared
(rather than the receiver of the instance_method call).

See ruby/ruby#6855
and https://bugs.ruby-lang.org/issues/18798

Co-authored-by: Manef Zahra <[email protected]>
Co-authored-by: Patrick Lin <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant