From 8ae6ad4251f94339bcbac08ec3cba8fed3fbc7f2 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Tue, 19 Nov 2019 17:19:34 +0100 Subject: [PATCH 1/2] Fix #7580: Desugar TupleXXL selection into `apply(n)` --- compiler/src/dotty/tools/dotc/ast/Desugar.scala | 5 ++++- compiler/test/dotc/pos-test-pickling.blacklist | 1 + tests/pos/i7580.scala | 5 +++++ 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 tests/pos/i7580.scala diff --git a/compiler/src/dotty/tools/dotc/ast/Desugar.scala b/compiler/src/dotty/tools/dotc/ast/Desugar.scala index 2adb4886ac07..fcf742fec9ee 100644 --- a/compiler/src/dotty/tools/dotc/ast/Desugar.scala +++ b/compiler/src/dotty/tools/dotc/ast/Desugar.scala @@ -1098,7 +1098,10 @@ object desugar { val firstDef = ValDef(tmpName, TypeTree(), matchExpr) .withSpan(pat.span.union(rhs.span)).withMods(patMods) - def selector(n: Int) = Select(Ident(tmpName), nme.selectorName(n)) + val arity = vars.length + def selector(n: Int) = + if arity <= 22 then Select(Ident(tmpName), nme.selectorName(n)) + else Apply(Select(Ident(tmpName), nme.apply), Literal(Constant(n)) :: Nil) val restDefs = for (((named, tpt), n) <- vars.zipWithIndex if named.name != nme.WILDCARD) yield diff --git a/compiler/test/dotc/pos-test-pickling.blacklist b/compiler/test/dotc/pos-test-pickling.blacklist index 59a9b8498080..e5c98b5666aa 100644 --- a/compiler/test/dotc/pos-test-pickling.blacklist +++ b/compiler/test/dotc/pos-test-pickling.blacklist @@ -28,6 +28,7 @@ i5720.scala # Tuples toexproftuple.scala +i7580.scala # Nullability nullable.scala diff --git a/tests/pos/i7580.scala b/tests/pos/i7580.scala new file mode 100644 index 000000000000..2e22da7fead9 --- /dev/null +++ b/tests/pos/i7580.scala @@ -0,0 +1,5 @@ + +def foo = + 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) + + () From 2e8ea243f50f7b086a9920ad3bec054b4d4bb478 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Tue, 19 Nov 2019 18:42:38 +0100 Subject: [PATCH 2/2] Factor out TupleXXL arity check --- compiler/src/dotty/tools/dotc/ast/Desugar.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/ast/Desugar.scala b/compiler/src/dotty/tools/dotc/ast/Desugar.scala index fcf742fec9ee..7f82e11ef8bf 100644 --- a/compiler/src/dotty/tools/dotc/ast/Desugar.scala +++ b/compiler/src/dotty/tools/dotc/ast/Desugar.scala @@ -1098,9 +1098,9 @@ object desugar { val firstDef = ValDef(tmpName, TypeTree(), matchExpr) .withSpan(pat.span.union(rhs.span)).withMods(patMods) - val arity = vars.length + val useSelectors = vars.length <= 22 def selector(n: Int) = - if arity <= 22 then Select(Ident(tmpName), nme.selectorName(n)) + if useSelectors then Select(Ident(tmpName), nme.selectorName(n)) else Apply(Select(Ident(tmpName), nme.apply), Literal(Constant(n)) :: Nil) val restDefs = for (((named, tpt), n) <- vars.zipWithIndex if named.name != nme.WILDCARD)