Skip to content

Issue with transformed tuples in an inline function (possibly compiler bug?) #16607

Discussion options

You must be logged in to vote

This code works:

import scala.deriving.*
import scala.compiletime.*

object Test {
  class Reader[A]()

  given Reader[Int] = Reader()
  given Reader[Double] = Reader()

  type PutReader[T] = T match {
    case (a, b) =>
      Reader[b]
  }

  inline def brokenTest[
    A,
  ](using
    aMirror: Mirror.ProductOf[A],
  ): Unit = {
    type AMap = Tuple.Zip[aMirror.MirroredElemLabels, aMirror.MirroredElemTypes] & NonEmptyTuple
    type Readers = Tuple.Map[AMap, PutReader]

    summonAll[Readers] // doesn't work
  }

  case class Foo(a: Int, b: Double)
  brokenTest[Foo]
}

I added & NonEmptyTuple at line 20 to explicitly tell the compiler that AMap is a NonEmptyTuple (note that it is unsafe b…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by oscar-broman
Comment options

You must be logged in to vote
2 replies
@Iltotore
Comment options

@oscar-broman
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants