@@ -345,10 +345,10 @@ object PatternMatcher {
345345
346346 // Disable Scala2Unapply optimization if the argument is a named argument for a single-element named tuple to
347347 // enable selecting the field. See i23131.scala for test cases.
348- val wasSingleNamedArgForNamedTuple =
348+ val wasUnaryNamedTupleSelectArgForNamedTuple =
349349 args.length == 1 && args.head.removeAttachment(FirstTransform .WasNamedArg ).isDefined &&
350350 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 )
352352 def tupleSel (sym : Symbol ) =
353353 // If scrutinee is a named tuple, cast to underlying tuple, so that we can
354354 // continue to select with _1, _2, ...
@@ -397,10 +397,11 @@ object PatternMatcher {
397397 // NamedArg trees are eliminated in FirstTransform but for named arguments
398398 // of patterns we add a WasNamedArg attachment, which is used to guide the
399399 // 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(_))
404405 matchArgsPlan(selectors, args, onSuccess)
405406 }
406407 }
0 commit comments