Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnboundMethod only refer defined_class #6855

Merged
merged 1 commit into from
Dec 2, 2022
Merged

Conversation

ko1
Copy link
Contributor

@ko1 ko1 commented Dec 2, 2022

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 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 <manef.zahra@shopify.com>
Co-authored-by: Patrick Lin <patrick.lin@shopify.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant