@@ -1899,11 +1899,16 @@ trait Applications extends Compatibility {
18991899 /** The type of alternative `alt` after instantiating its first parameter
19001900 * clause with `argTypes`.
19011901 */
1902- def skipParamClause (argTypes : List [Type ])(alt : TermRef ): Type =
1902+ def skipParamClause (argTypes : List [Type ], typeArgs : List [ Type ] )(alt : TermRef ): Type =
19031903 def skip (tp : Type ): Type = tp match {
19041904 case tp : PolyType =>
1905- val rt = skip(tp.resultType)
1906- if rt.exists then tp.derivedLambdaType(resType = rt).asInstanceOf [PolyType ].flatten else rt
1905+ skip(tp.resultType) match
1906+ case NoType =>
1907+ NoType
1908+ case rt : PolyType if typeArgs.length == rt.paramInfos.length =>
1909+ tp.derivedLambdaType(resType = rt.instantiate(typeArgs))
1910+ case rt =>
1911+ tp.derivedLambdaType(resType = rt).asInstanceOf [PolyType ].flatten
19071912 case tp : MethodType =>
19081913 tp.instantiate(argTypes)
19091914 case _ =>
@@ -1926,9 +1931,14 @@ trait Applications extends Compatibility {
19261931 else
19271932 val deepPt = pt.deepenProto
19281933 deepPt match
1934+ case pt @ FunProto (_, PolyProto (targs, resType)) =>
1935+ // try to narrow further with snd argument list and following type params
1936+ resolveMapped(candidates,
1937+ skipParamClause(pt.typedArgs().tpes, targs.tpes), resType)
19291938 case pt @ FunProto (_, resType : FunOrPolyProto ) =>
19301939 // try to narrow further with snd argument list
1931- resolveMapped(candidates, skipParamClause(pt.typedArgs().tpes), resType)
1940+ resolveMapped(candidates,
1941+ skipParamClause(pt.typedArgs().tpes, Nil ), resType)
19321942 case _ =>
19331943 // prefer alternatives that need no eta expansion
19341944 val noCurried = alts.filter(! resultIsMethod(_))
0 commit comments