Skip to content

Commit 4e684dc

Browse files
committed
more precise check
1 parent 2183e53 commit 4e684dc

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,8 @@ object PatternMatcher {
343343
receiver.ensureConforms(defn.NonEmptyTupleTypeRef), // If scrutinee is a named tuple, cast to underlying tuple
344344
Literal(Constant(i)))
345345

346-
if (isSyntheticScala2Unapply(unapp.symbol) && caseAccessors.length == args.length && args.length != 1)
346+
val wasNamedArg = args.length == 1 && args.head.removeAttachment(FirstTransform.WasNamedArg).isDefined
347+
if (isSyntheticScala2Unapply(unapp.symbol) && caseAccessors.length == args.length && !wasNamedArg)
347348
def tupleSel(sym: Symbol) =
348349
// If scrutinee is a named tuple, cast to underlying tuple, so that we can
349350
// continue to select with _1, _2, ...
@@ -388,7 +389,7 @@ object PatternMatcher {
388389
letAbstract(get) { getResult =>
389390
def isUnaryNamedTupleSelectArg(arg: Tree) =
390391
get.tpe.widenDealias.isNamedTupleType
391-
&& arg.removeAttachment(FirstTransform.WasNamedArg).isDefined
392+
&& wasNamedArg
392393
// Special case: Normally, we pull out the argument wholesale if
393394
// there is only one. But if the argument is a named argument for
394395
// a single-element named tuple, we have to select the field instead.

0 commit comments

Comments
 (0)