Skip to content

Commit 8031978

Browse files
Merge pull request #5322 from dotty-staging/fix-#5271
Fix #5271: Use typed elements
2 parents 05ddfda + 054cfae commit 8031978

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1794,22 +1794,21 @@ 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)
1805-
val elems1 = (tree.trees, pts).zipped.map(typed(_, _))
1803+
else List.fill(arity)(defn.AnyType)
1804+
val elems = (tree.trees, pts).zipped.map(typed(_, _))
18061805
if (ctx.mode.is(Mode.Type))
1807-
(elems1 :\ (TypeTree(defn.UnitType): Tree))((elemTpt, elemTpts) =>
1806+
(elems :\ (TypeTree(defn.UnitType): Tree))((elemTpt, elemTpts) =>
18081807
AppliedTypeTree(TypeTree(defn.PairType), List(elemTpt, elemTpts)))
18091808
.withPos(tree.pos)
18101809
else {
18111810
val tupleXXLobj = untpd.ref(defn.TupleXXLModule.termRef)
1812-
val app = untpd.cpy.Apply(tree)(tupleXXLobj, elems1.map(untpd.TypedSplice(_)))
1811+
val app = untpd.cpy.Apply(tree)(tupleXXLobj, elems.map(untpd.TypedSplice(_)))
18131812
.withPos(tree.pos)
18141813
val app1 = typed(app, defn.TupleXXLType)
18151814
if (ctx.mode.is(Mode.Pattern)) app1

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)