diff options
author | nagachika <nagachika@ruby-lang.org> | 2021-03-20 14:26:30 +0900 |
---|---|---|
committer | nagachika <nagachika@ruby-lang.org> | 2021-03-20 14:26:30 +0900 |
commit | 82d72f14e7071218f3fd710f770d1ba31390f027 (patch) | |
tree | 5d5cad384cba513f46290df64835aafe7fb7c943 /version.h | |
parent | 6ef46f71c743507a0e2ae0eef14dce0539b0ff52 (diff) |
merge revision(s) ebb96fa8808317ad53a4977bff26cf755d68077e: [Backport #17321]
Fix singleton class cloning
Before this commit, `clone` gave different results depending on whether the original object
had an attached singleton class or not.
Consider the following setup:
```
class Foo; end
Foo.singleton_class.define_method(:foo) {}
obj = Foo.new
obj.singleton_class if $call_singleton
clone = obj.clone
```
When `$call_singleton = false`, neither `obj.singleton_class.singleton_class` nor
`clone.singleton_class.singleton_class` own any methods.
However, when `$call_singleton = true`, `clone.singleton_class.singleton_class` would own a copy of
`foo` from `Foo.singleton_class`, even though `obj.singleton_class.singleton_class` does not.
The latter case is unexpected and results in a visibly different clone, depending on if the original object
had an attached class or not.
Co-authored-by: Ufuk Kayserilioglu <ufuk.kayserilioglu@shopify.com>
---
class.c | 31 ++++++++++++++++++++++---------
test/ruby/test_class.rb | 47 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 69 insertions(+), 9 deletions(-)
Diffstat (limited to 'version.h')
-rw-r--r-- | version.h | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -2,7 +2,7 @@ # define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR #define RUBY_VERSION_TEENY 3 #define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR -#define RUBY_PATCHLEVEL 168 +#define RUBY_PATCHLEVEL 169 #define RUBY_RELEASE_YEAR 2021 #define RUBY_RELEASE_MONTH 3 |