Skip to content

Tuple.fromProduct doesn't handle Product0 #11792

Closed
@sirthias

Description

@sirthias

Compiler version

3.0.0-RC1

Minimized code

scala> case class Foo()
// defined case class Foo

scala> Tuple.fromProduct(Foo())
java.lang.AssertionError: assertion failed
  at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:11)
  at scala.runtime.TupleXXL.<init>(TupleXXL.scala:4)
  at scala.runtime.TupleXXL$.fromIArray(TupleXXL.scala:45)
  at scala.runtime.Tuples$.fromProduct(Tuples.scala:174)
  at scala.Tuple$.fromProduct(Tuple.scala:229)
  ... 27 elided

Expectation

Tuple.fromProduct(Foo()) should return EmptyTuple.

On this note: Why is it called EmptyTuple instead of Tuple0?
We have Function0, Product0 (at least I think we do) and EmptyTuple, which appears to be inconsistent naming-wise.

Solution

The match in scala.runtime.Tuples.fromProduct simply needs another branch, similar to the one already present in fromArray.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions