Repository navigation
Revert IO::Buffer subclass-preserving types for ruby-head - #3196
Merged
Merged
Conversation
…ests ruby-head (5b6f593531, "Introduce (internal) IO::Buffer::Storage and Slice") removed the allocator from IO::Buffer and made Storage the allocatable subclass. The test-only `Class.new(IO::Buffer)` subclass can no longer be instantiated, and IO::Buffer.for/.string reject it, which broke the stdlib_test job on ruby-head. Since that design is still internal and likely to change, go back to the plain `Buffer` types for IO::Buffer.for, .string, #slice and #transfer, and exercise the remaining `self`-returning methods with plain IO::Buffer instances. The optional-argument forms of #slice are kept. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
stdlib_teston ruby-head started failing in the merge queue (e.g. for #3193) after ruby/ruby5b6f593531("Introduce (internal)IO::Buffer::StorageandSlice") landed.IO::Bufferno longer has an allocator,IO::Buffer.newbecame a factory forIO::Buffer::Storage, and.for/.stringraiseStorage factory requires IO::Buffer::Storage!for any class that is not a Storage subclass. The tests added in #3190 useClass.new(IO::Buffer), which now fails withallocator undefined.That design is marked internal and is likely to change, so rather than branching on the Ruby version this PR drops the subclass-dependent parts:
IO::Buffer.for,IO::Buffer.string,#sliceand#transfergo back to returning/yieldingBufferinstead ofinstance/self.#sliceare kept.BufferSubclassis removed from the tests; theself-returning methods (and!,each, ...) are tested with plainIO::Bufferinstances.Test plan
bundle exec ruby -Ilib bin/test_runner.rb test/stdlib/io/Buffer_test.rbpasses locally on Ruby 4.0.6 (42 tests, 0 failures).🤖 Generated with Claude Code