-
-
Notifications
You must be signed in to change notification settings - Fork 942
Closed
Milestone
Description
I ran into this edge-case when working with classes which inherit from Set (I know, I probably shouldn't do that) and the classes contain other instance variables which require custom initialize_copy logic to copy them over when the set is duplicated, such as when Set#| is called; the implementation of Set#| on both CRuby and JRuby is essentially dup.merge(other).
Under JRuby (9.3.1.0), the custom initialize_copy method does not seem to be called when Set#dup is called.
Steps To Reproduce
require 'set'
class FooObject
def initialize_copy(other)
puts "#{self.class}#initialize_copy called!"
end
end
class FooSet < Set
def initialize_copy(other)
puts "#{self.class}#initialize_copy called!"
end
end
obj = FooObject.new
obj.dup
set = FooSet.new
set.dupCRuby 2.7.4
FooObject#initialize_copy called!
FooSet#initialize_copy called!
CRuby 3.0.2
FooObject#initialize_copy called!
FooSet#initialize_copy called!
JRuby 9.3.1.0
FooObject#initialize_copy called!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels