From 21be611112d4c01de4c0b9368e433395d878e298 Mon Sep 17 00:00:00 2001 From: odersky Date: Sun, 26 Nov 2023 14:30:49 +0100 Subject: [PATCH] Refine handling of pattern binders for large tuples --- compiler/src/dotty/tools/dotc/typer/Typer.scala | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index 194d84d0dd0d..9310a4acd8ae 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -2434,7 +2434,13 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer // wrt to operand order for `&`, we include the explicit subtype test here. // See also #5649. then body1.tpe - else pt & body1.tpe + else body1.tpe match + case btpe: TypeRef + if btpe.symbol == defn.TupleXXLClass && pt.tupleElementTypes.isDefined => + // leave the original tuple type; don't mix with & TupleXXL which would only obscure things + pt + case _ => + pt & body1.tpe val sym = newPatternBoundSymbol(name, symTp, tree.span) if (pt == defn.ImplicitScrutineeTypeRef || tree.mods.is(Given)) sym.setFlag(Given) if (ctx.mode.is(Mode.InPatternAlternative))