Skip to content

Commit

Permalink
Fix tupleTypeFromSeq for XXL tuples
Browse files Browse the repository at this point in the history
  • Loading branch information
joroKr21 committed Oct 16, 2024
1 parent f6bfa0a commit af9ee8e
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
2 changes: 1 addition & 1 deletion library/src/scala/quoted/Expr.scala
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ object Expr {
private def tupleTypeFromSeq(seq: Seq[Expr[Any]])(using Quotes): quotes.reflect.TypeRepr =
import quotes.reflect.*
val consRef = Symbol.classSymbol("scala.*:").typeRef
seq.foldLeft(TypeRepr.of[EmptyTuple]) { (ts, expr) =>
seq.foldRight(TypeRepr.of[EmptyTuple]) { (expr, ts) =>
AppliedType(consRef, expr.asTerm.tpe :: ts :: Nil)
}

Expand Down
36 changes: 36 additions & 0 deletions tests/pos/i21779/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import scala.quoted.*

object Macro:
transparent inline def tupleXxl: Tuple =
${tupleXxlExpr}

def tupleXxlExpr(using Quotes) =
import quotes.reflect.*
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),
)
)

3 changes: 3 additions & 0 deletions tests/pos/i21779/Test_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
object Test:
val result: ("a", 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23) =
Macro.tupleXxl

0 comments on commit af9ee8e

Please sign in to comment.