@@ -1570,28 +1570,25 @@ trait Applications extends Compatibility {
1570
1570
def trySelectUnapply (qual : untpd.Tree )(fallBack : (Tree , TyperState ) => Tree ): Tree = {
1571
1571
// try first for non-overloaded, then for overloaded occurrences
1572
1572
def tryWithName (name : TermName )(fallBack : (Tree , TyperState ) => Tree )(using Context ): Tree =
1573
- /** Returns `true` if there are type parameters after the last explicit
1574
- * (non-implicit) term parameters list.
1575
- */
1576
- @ tailrec
1577
- def hasTrailingTypeParams (paramss : List [List [Symbol ]], acc : Boolean = false ): Boolean =
1573
+ // `true` if there are type parameters not followed by explicit term parameters.
1574
+ def hasTrailingTypeParams (paramss : List [List [Symbol ]], trailingTypeParams : Boolean ): Boolean =
1578
1575
paramss match
1579
- case Nil => acc
1580
- case params :: rest =>
1581
- val newAcc =
1582
- params match
1583
- case param :: _ if param.isType => true
1584
- case param :: _ if param.isTerm && ! param.isOneOf( GivenOrImplicit ) => false
1585
- case _ => acc
1586
- hasTrailingTypeParams(paramss.tail, newAcc)
1576
+ case params :: paramss =>
1577
+ val isTrailingTypeParams =
1578
+ params match
1579
+ case param :: _ if param.isType => true
1580
+ case param :: _ if param.isTerm && ! param.isOneOf( GivenOrImplicit ) => false
1581
+ case _ => trailingTypeParams
1582
+ hasTrailingTypeParams(paramss, isTrailingTypeParams)
1583
+ case nil => trailingTypeParams
1587
1584
1588
1585
def tryWithProto (qual : untpd.Tree , targs : List [Tree ], pt : Type )(using Context ) =
1589
1586
val proto = UnapplyFunProto (pt, this )
1590
1587
val unapp = untpd.Select (qual, name)
1591
1588
val result =
1592
1589
if targs.isEmpty then typedExpr(unapp, proto)
1593
1590
else typedExpr(unapp, PolyProto (targs, proto)).appliedToTypeTrees(targs)
1594
- if result.symbol.exists && hasTrailingTypeParams(result.symbol.paramSymss) then
1591
+ if result.symbol.exists && hasTrailingTypeParams(result.symbol.paramSymss, trailingTypeParams = false ) then
1595
1592
// We don't accept `unapply` or `unapplySeq` methods with type
1596
1593
// parameters after the last explicit term parameter because we
1597
1594
// can't encode them: `UnApply` nodes cannot take type paremeters.
0 commit comments