From b1fb67cb188e237b143731f1f65178472b86016b Mon Sep 17 00:00:00 2001 From: Eugene Flesselle Date: Wed, 6 Aug 2025 18:07:11 +0200 Subject: [PATCH] Fix auto-untupling for generic tuple types This makes the behaviour of auto-untupling consistent between the usual and generic tuples. Related to https://github.com/scala/scala3/pull/23602 --- compiler/src/dotty/tools/dotc/typer/Applications.scala | 2 +- tests/pos/generic-untupling.scala | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 tests/pos/generic-untupling.scala diff --git a/compiler/src/dotty/tools/dotc/typer/Applications.scala b/compiler/src/dotty/tools/dotc/typer/Applications.scala index da6b20b75c29..2e9288dcd9be 100644 --- a/compiler/src/dotty/tools/dotc/typer/Applications.scala +++ b/compiler/src/dotty/tools/dotc/typer/Applications.scala @@ -280,7 +280,7 @@ object Applications { case argType :: Nil if args.lengthCompare(1) > 0 && Feature.autoTuplingEnabled - && defn.isTupleNType(argType) => + && (defn.isTupleNType(argType) || argType.isSmallGenericTuple) => untpd.Tuple(args) :: Nil case _ => args diff --git a/tests/pos/generic-untupling.scala b/tests/pos/generic-untupling.scala new file mode 100644 index 000000000000..b6002301baec --- /dev/null +++ b/tests/pos/generic-untupling.scala @@ -0,0 +1,8 @@ + +def foo(x: Option[(Int, Boolean)]) = x match + case Some(a, b) => ??? // was ok + case None => ??? + +def bar(x: Option[Int *: Boolean *: EmptyTuple]) = x match + case Some(a, b) => ??? // was error, now ok + case None => ???