@@ -345,10 +345,10 @@ object PatternMatcher {
345
345
346
346
// Disable Scala2Unapply optimization if the argument is a named argument for a single-element named tuple to
347
347
// enable selecting the field. See i23131.scala for test cases.
348
- val wasSingleNamedArgForNamedTuple =
348
+ val wasUnaryNamedTupleSelectArgForNamedTuple =
349
349
args.length == 1 && args.head.removeAttachment(FirstTransform .WasNamedArg ).isDefined &&
350
350
isGetMatch(unappType) && unapp.select(nme.get, _.info.isParameterless).tpe.widenDealias.isNamedTupleType
351
- if (isSyntheticScala2Unapply(unapp.symbol) && caseAccessors.length == args.length && ! wasSingleNamedArgForNamedTuple )
351
+ if (isSyntheticScala2Unapply(unapp.symbol) && caseAccessors.length == args.length && ! wasUnaryNamedTupleSelectArgForNamedTuple )
352
352
def tupleSel (sym : Symbol ) =
353
353
// If scrutinee is a named tuple, cast to underlying tuple, so that we can
354
354
// continue to select with _1, _2, ...
@@ -397,10 +397,11 @@ object PatternMatcher {
397
397
// NamedArg trees are eliminated in FirstTransform but for named arguments
398
398
// of patterns we add a WasNamedArg attachment, which is used to guide the
399
399
// logic here. See i22900.scala for test cases.
400
- val selectors = if args.length == 1 && ! wasSingleNamedArgForNamedTuple then
401
- ref(getResult) :: Nil
402
- else
403
- productSelectors(getResult.info).map(ref(getResult).select(_))
400
+ val selectors = args match
401
+ case arg :: Nil if ! wasUnaryNamedTupleSelectArgForNamedTuple =>
402
+ ref(getResult) :: Nil
403
+ case _ =>
404
+ productSelectors(getResult.info).map(ref(getResult).select(_))
404
405
matchArgsPlan(selectors, args, onSuccess)
405
406
}
406
407
}
0 commit comments