@@ -1570,25 +1570,25 @@ trait Applications extends Compatibility {
15701570    def  trySelectUnapply (qual : untpd.Tree )(fallBack : (Tree , TyperState ) =>  Tree ):  Tree  =  {
15711571      //  try first for non-overloaded, then for overloaded occurrences
15721572      def  tryWithName (name : TermName )(fallBack : (Tree , TyperState ) =>  Tree )(using  Context ):  Tree  = 
1573-         //  `true` if there are type parameters not followed by  explicit term parameters .
1574-         def  hasTrailingTypeParams (paramss : List [List [Symbol ]],  trailingTypeParams :  Boolean ):  Boolean  = 
1575-           paramss  match 
1576-           case  params  ::   paramss => 
1577-             val   isTrailingTypeParams   = 
1573+         //  `true` if there are no  type parameters following the first  explicit term parameter .
1574+         def  hasOnlyLeadingTypeParams (paramss : List [List [Symbol ]]):  Boolean  = 
1575+           def   checkForIt ( paramss :  List [ List [ Symbol ]],  leading :  Boolean ) :   Boolean   = 
1576+              paramss match 
1577+             case  params  ::  paramss  => 
15781578              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 
1579+               case  param ::  _ if  param.isType &&   ! leading  =>  false 
1580+               case  param ::  _ if  param.isTerm &&  ! param.isOneOf(GivenOrImplicit ) =>  checkForIt(paramss, leading  =   false ) 
1581+               case  _ =>  checkForIt(paramss, leading) 
1582+             case  nil  =>   true 
1583+           checkForIt(paramss, leading  =   true ) 
15841584
15851585        def  tryWithProto (qual : untpd.Tree , targs : List [Tree ], pt : Type )(using  Context ) = 
15861586          val  proto  =  UnapplyFunProto (pt, this )
15871587          val  unapp  =  untpd.Select (qual, name)
15881588          val  result  = 
15891589            if  targs.isEmpty then  typedExpr(unapp, proto)
15901590            else  typedExpr(unapp, PolyProto (targs, proto)).appliedToTypeTrees(targs)
1591-           if  result.symbol.exists &&  hasTrailingTypeParams (result.symbol.paramSymss, trailingTypeParams  =   false ) then 
1591+           if  result.symbol.exists &&  ! hasOnlyLeadingTypeParams (result.symbol.paramSymss) then 
15921592            //  We don't accept `unapply` or `unapplySeq` methods with type
15931593            //  parameters after the last explicit term parameter because we
15941594            //  can't encode them: `UnApply` nodes cannot take type paremeters.
0 commit comments