diff --git a/compiler/src/dotty/tools/dotc/typer/Applications.scala b/compiler/src/dotty/tools/dotc/typer/Applications.scala index 7ada64b2c50b..0159850b6d63 100644 --- a/compiler/src/dotty/tools/dotc/typer/Applications.scala +++ b/compiler/src/dotty/tools/dotc/typer/Applications.scala @@ -1358,9 +1358,10 @@ trait Applications extends Compatibility { var argTypes = unapplyArgs(unapplyApp.tpe, unapplyFn, args, tree.srcPos) for (argType <- argTypes) assert(!isBounds(argType), unapplyApp.tpe.show) val bunchedArgs = argTypes match { - case argType :: Nil => - if (args.lengthCompare(1) > 0 && Feature.autoTuplingEnabled) untpd.Tuple(args) :: Nil - else args + case (argType : AppliedType) :: Nil + if (defn.isTupleClass(argType.tycon.typeSymbol)) && + (args.lengthCompare(1) > 0 && Feature.autoTuplingEnabled) => + untpd.Tuple(args) :: Nil case _ => args } if (argTypes.length != bunchedArgs.length) { diff --git a/tests/neg/i10757.scala b/tests/neg/i10757.scala new file mode 100644 index 000000000000..604317d05fa1 --- /dev/null +++ b/tests/neg/i10757.scala @@ -0,0 +1,4 @@ +case class Var(name: String) + +@main def f = Var("a") match + case Var(name, _) => name: String // error: Wrong number of argument patterns for Var; expected: (String)