summaryrefslogtreecommitdiff
path: root/internal.h
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2021-04-05 00:19:04 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2021-04-05 00:19:04 +0000
commita5272e643121a2e5f51f3cfb2f0899520afafd27 (patch)
tree62b4d2aff41b6562d290c7d1798eca6ee39ea495 /internal.h
parent082b0acffb9eb93c350b5b04fc59509fa9329786 (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(-) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_6@67935 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'internal.h')
0 files changed, 0 insertions, 0 deletions