Skip to content

Commit d076274

Browse files
committed
Fix #5271: Use typed elements
1 parent 05ddfda commit d076274

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1794,14 +1794,13 @@ class Typer extends Namer
17941794

17951795
/** Translate tuples of all arities */
17961796
def typedTuple(tree: untpd.Tuple, pt: Type)(implicit ctx: Context): Tree = {
1797-
val elems = tree.trees
1798-
val arity = elems.length
1797+
val arity = tree.trees.length
17991798
if (arity <= Definitions.MaxTupleArity)
18001799
typed(desugar.smallTuple(tree).withPos(tree.pos), pt)
18011800
else {
18021801
val pts =
18031802
if (arity == pt.tupleArity) pt.tupleElementTypes
1804-
else elems.map(_ => defn.AnyType)
1803+
else List.fill(arity)(defn.AnyType)
18051804
val elems1 = (tree.trees, pts).zipped.map(typed(_, _))
18061805
if (ctx.mode.is(Mode.Type))
18071806
(elems1 :\ (TypeTree(defn.UnitType): Tree))((elemTpt, elemTpts) =>
@@ -1814,7 +1813,7 @@ class Typer extends Namer
18141813
val app1 = typed(app, defn.TupleXXLType)
18151814
if (ctx.mode.is(Mode.Pattern)) app1
18161815
else {
1817-
val elemTpes = (elems, pts).zipped.map((elem, pt) =>
1816+
val elemTpes = (elems1, pts).zipped.map((elem, pt) =>
18181817
ctx.typeComparer.widenInferred(elem.tpe, pt))
18191818
val resTpe = (elemTpes :\ (defn.UnitType: Type))(defn.PairType.appliedTo(_, _))
18201819
app1.asInstance(resTpe)

tests/pos/i5271.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class Foo {
2+
def foo: Unit = {
3+
val (_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) =
4+
(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, List(2, 1), 22, 23)
5+
}
6+
}

0 commit comments

Comments
 (0)