Skip to content

Lambda-accepting UnsafeBufferOperations need contracts for calls-in-place #361

Closed
@JakeWharton

Description

@JakeWharton

Kotlin 2.0 can see through inline funs now, but it does not infer calls-in-place.

One workaround for #360 would be to do

	override fun readAtMostTo(sink: Buffer, byteCount: Long): Long {
		val bytesRead: Int
		UnsafeBufferOperations.writeToTail(sink, 1) { bytes, startIndexInclusive, endIndexExclusive ->
			val read: Int = TODO()
			bytesRead = read
			read
		}
		return bytesRead.toLong()
	}

except without the contract the compiler complains bytesRead is not initialized at the return.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions