Skip to content

Commit 32a3781

Browse files
authored
Merge pull request #7583 from dotty-staging/fix-#7580
Fix #7580: Desugar TupleXXL selection into `apply(n)`
2 parents 88500ff + 2e8ea24 commit 32a3781

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

compiler/src/dotty/tools/dotc/ast/Desugar.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1098,7 +1098,10 @@ object desugar {
10981098
val firstDef =
10991099
ValDef(tmpName, TypeTree(), matchExpr)
11001100
.withSpan(pat.span.union(rhs.span)).withMods(patMods)
1101-
def selector(n: Int) = Select(Ident(tmpName), nme.selectorName(n))
1101+
val useSelectors = vars.length <= 22
1102+
def selector(n: Int) =
1103+
if useSelectors then Select(Ident(tmpName), nme.selectorName(n))
1104+
else Apply(Select(Ident(tmpName), nme.apply), Literal(Constant(n)) :: Nil)
11021105
val restDefs =
11031106
for (((named, tpt), n) <- vars.zipWithIndex if named.name != nme.WILDCARD)
11041107
yield

compiler/test/dotc/pos-test-pickling.blacklist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ i5720.scala
2828

2929
# Tuples
3030
toexproftuple.scala
31+
i7580.scala
3132

3233
# Nullability
3334
nullable.scala

tests/pos/i7580.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
def foo =
3+
val List(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, _:_*) = List.fill(25)(0)
4+
5+
()

0 commit comments

Comments
 (0)