@@ -1899,11 +1899,16 @@ trait Applications extends Compatibility {
1899
1899
/** The type of alternative `alt` after instantiating its first parameter
1900
1900
* clause with `argTypes`.
1901
1901
*/
1902
- def skipParamClause (argTypes : List [Type ])(alt : TermRef ): Type =
1902
+ def skipParamClause (argTypes : List [Type ], typeArgs : List [ Type ] )(alt : TermRef ): Type =
1903
1903
def skip (tp : Type ): Type = tp match {
1904
1904
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
1907
1912
case tp : MethodType =>
1908
1913
tp.instantiate(argTypes)
1909
1914
case _ =>
@@ -1926,9 +1931,14 @@ trait Applications extends Compatibility {
1926
1931
else
1927
1932
val deepPt = pt.deepenProto
1928
1933
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)
1929
1938
case pt @ FunProto (_, resType : FunOrPolyProto ) =>
1930
1939
// 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)
1932
1942
case _ =>
1933
1943
// prefer alternatives that need no eta expansion
1934
1944
val noCurried = alts.filter(! resultIsMethod(_))
0 commit comments