Skip to content

Support obj.clone(freeze: true) for freezing clone - #2969

Merged
jeremyevans merged 1 commit into
ruby:masterfrom
jeremyevans:clone-freeze-true-16175
Mar 22, 2020
Merged

Support obj.clone(freeze: true) for freezing clone#2969
jeremyevans merged 1 commit into
ruby:masterfrom
jeremyevans:clone-freeze-true-16175

Conversation

@jeremyevans

Copy link
Copy Markdown
Contributor

This freezes the clone even if the receiver is not frozen. It
is only for consistency with freeze: false not freezing the clone
even if the receiver is frozen.

Because Object#clone is now partially implemented in Ruby and
not fully implemented in C, freeze: nil must be supported to
provide the default behavior of only freezing the clone if the
receiver is frozen.

This requires modifying delegate and set, to set freeze: nil
instead of freeze: true as the keyword parameter for
initialize_clone. Those are the two libraries in stdlib that
override initialize_clone.

Implements [Feature #16175]

@jeremyevans
jeremyevans force-pushed the clone-freeze-true-16175 branch 3 times, most recently from 753b826 to bc3b86f Compare March 21, 2020 15:30
This freezes the clone even if the receiver is not frozen.  It
is only for consistency with freeze: false not freezing the clone
even if the receiver is frozen.

Because Object#clone is now partially implemented in Ruby and
not fully implemented in C, freeze: nil must be supported to
provide the default behavior of only freezing the clone if the
receiver is frozen.

This requires modifying delegate and set, to set freeze: nil
instead of freeze: true as the keyword parameter for
initialize_clone.  Those are the two libraries in stdlib that
override initialize_clone.

Implements [Feature ruby#16175]
@jeremyevans
jeremyevans force-pushed the clone-freeze-true-16175 branch from bc3b86f to 8d687a4 Compare March 22, 2020 15:35
@jeremyevans
jeremyevans merged commit 4f7b435 into ruby:master Mar 22, 2020
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