Skip to content

Issue with enqueuing an akka ByteString to an immutable Queue #17946

Open
@pjfanning

Description

@pjfanning

Compiler version

Scala 3.3.0

Minimized code

https://scastie.scala-lang.org/pjfanning/nrTQr59WTAy2uIMYUFtkTw/4

val byteString = akka.util.ByteString("abc")
var queue = scala.collection.immutable.Queue.empty[akka.util.ByteString]
queue = queue.enqueue(byteString)

This code works in Scala 2.13 but fails to compile in Scala 3.3.0.

A minimised example that reproduces this:

class MyByteString extends Iterable[Byte] {
  override def iterator: Iterator[Byte] = ???
}

val byteString = new MyByteString
var queue = scala.collection.immutable.Queue.empty[MyByteString]
queue = queue.enqueue(byteString)

Output

Compiler issue on the queue = queue.enqueue(byteString) call

Found:    akka.util.ByteString
Required: Iterable[akka.util.ByteString]

Expectation

This should compile.

I think Scala3 is confused by the fact that akka.util.ByteString extends Iterable[Byte] but the Queue is explicitly setup to be Queue[ByteString].

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