Skip to content

Expr.ofTupleFromSeq return incorrect value if TupleXXL #21779

Closed
@xuwei-k

Description

@xuwei-k

Compiler version

  • 3.6.1-RC1-bin-20241014-69ac5fb-NIGHTLY
  • 3.5.1
  • 3.3.4

Minimized code

build.sbt

scalaVersion := "3.5.1"

libraryDependencies += "org.scala-lang" %% "scala3-staging" % scalaVersion.value

Main.scala

import scala.quoted.*
import scala.quoted.staging.{withQuotes, Compiler}

object Main {

  given Compiler = Compiler.make(getClass.getClassLoader)

  def main(args: Array[String]): Unit = {
    withQuotes {
      import quotes.reflect.*
      val x1 = Expr.ofTupleFromSeq(
        Seq(
          Expr("a"),
          Expr(2),
          Expr(3),
          Expr(4),
          Expr(5),
          Expr(6),
          Expr(7),
          Expr(8),
          Expr(9),
          Expr(10),
          Expr(11),
          Expr(12),
          Expr(13),
          Expr(14),
          Expr(15),
          Expr(16),
          Expr(17),
          Expr(18),
          Expr(19),
          Expr(20),
          Expr(21),
          Expr(22),
        )
      )

      val x2 = Expr.ofTupleFromSeq(
        Seq(
          Expr("a"),
          Expr(2),
          Expr(3),
          Expr(4),
          Expr(5),
          Expr(6),
          Expr(7),
          Expr(8),
          Expr(9),
          Expr(10),
          Expr(11),
          Expr(12),
          Expr(13),
          Expr(14),
          Expr(15),
          Expr(16),
          Expr(17),
          Expr(18),
          Expr(19),
          Expr(20),
          Expr(21),
          Expr(22),
          Expr(23),
        )
      )
      println(x1.asTerm.tpe.show)
      println(x2.asTerm.tpe.show)

      assert(x1.asTerm.tpe =:= TypeRepr.of[("a", 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22)])

      // success !?!?!?
      // expect `TypeRepr.of[("a", 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23)]`
      assert(x2.asTerm.tpe =:= TypeRepr.of[(23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, "a")])
    }
  }
}

Output

Expectation

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions