Skip to content

Update Kotlin to 2.3 and enable RVC#491

Merged
fzhinkin merged 6 commits intodevelopfrom
kotlin-2.3
Jan 14, 2026
Merged

Update Kotlin to 2.3 and enable RVC#491
fzhinkin merged 6 commits intodevelopfrom
kotlin-2.3

Conversation

@fzhinkin
Copy link
Copy Markdown
Collaborator

@fzhinkin fzhinkin commented Jan 6, 2026

A few functions were annotated as ignorable, they could be categorized in a following way:

  1. Functions returning the receiver:
  • Base64.encodeToAppendable
  • Buffer.transferFrom
  • Buffer.write
  1. Functions returning number of bytes read/written:
  • Sink.transferFrom
  • Source.transferTo

For the first group, everything is trivial: functions returns a receiver, and unless a users wants chaining calls, it's fine to ignore the result.

The number of consumed bytes should not be ignorable in general, but Sink.transferFrom/Source.transferTo consumes everything from the source and unless it is necessary to know how many bytes were there, it is safe to ignore the result. For comparison, functions like readAtMostTo consumes a variable number of bytes and also indicate an exhaustion by retuning a negative value, thus their results have to be checked.

There is a third group of functions that I considered annotating as functions with ignorable results, but abstained from doing that: unsafe operations. All those operations return the number of read/written bytes, but in all use cases within the library, that value could be safely ignored, because the actual number of transferred bytes is tracked elsewhere. I think it is safe to leave them non-ignorable for now, and reconsider this decision later.

@fzhinkin fzhinkin requested a review from shanshin January 6, 2026 15:27
Comment thread core/common/test/AbstractSourceTest.kt Outdated

// Reset.
source.readString()
val _ = source.readString()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just thinking out loud: in reality, is this a frequent case, do we need a method like skipAll()?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll check if anyone uses something like that. For now, replaced it with source.transferTo(discardingSink())

Comment thread core/common/test/CommonBufferTest.kt Outdated
val sink = Buffer()
sink.writeString('b'.repeat(Segment.SIZE - 10)) // limit = size - 10
sink.readString((Segment.SIZE - 20).toLong()) // pos = size = 20
val _ = sink.readString((Segment.SIZE - 20).toLong()) // pos = size = 20
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can it be replaced by skip(n)?
It's not entirely obvious why to read a string in such a place and then ignore its value.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thanks for pointing to it!

}
parts.asReversed().forEach {
fs.mkdirSync(it)
val _ = fs.mkdirSync(it)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we briefly write why we ignore it? Without knowledge of the JS API, it looked dangerous.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It returns undefined in all cases but when recursive (there is no such parameter in our declaration) is true (it returns the first created path then).
I changed the return type to Unit for now.

Base automatically changed from 484-fix-wasi-fs-implementation to develop January 14, 2026 16:52
@fzhinkin fzhinkin merged commit dd71bc1 into develop Jan 14, 2026
1 check passed
@fzhinkin fzhinkin deleted the kotlin-2.3 branch January 14, 2026 18:24
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.

2 participants