@@ -1897,13 +1897,19 @@ trait Applications extends Compatibility {
1897
1897
}
1898
1898
1899
1899
/** The type of alternative `alt` after instantiating its first parameter
1900
- * clause with `argTypes`.
1900
+ * clause with `argTypes`. In addition, if the resulting type is a PolyType
1901
+ * and `typeArgs` matches its parameter list, instantiate the result with `typeArgs`.
1901
1902
*/
1902
- def skipParamClause (argTypes : List [Type ])(alt : TermRef ): Type =
1903
+ def skipParamClause (argTypes : List [Type ], typeArgs : List [ Type ] )(alt : TermRef ): Type =
1903
1904
def skip (tp : Type ): Type = tp match {
1904
1905
case tp : PolyType =>
1905
- val rt = skip(tp.resultType)
1906
- if (rt.exists) tp.derivedLambdaType(resType = rt) else rt
1906
+ skip(tp.resultType) match
1907
+ case NoType =>
1908
+ NoType
1909
+ case rt : PolyType if typeArgs.length == rt.paramInfos.length =>
1910
+ tp.derivedLambdaType(resType = rt.instantiate(typeArgs))
1911
+ case rt =>
1912
+ tp.derivedLambdaType(resType = rt).asInstanceOf [PolyType ].flatten
1907
1913
case tp : MethodType =>
1908
1914
tp.instantiate(argTypes)
1909
1915
case _ =>
@@ -1926,9 +1932,14 @@ trait Applications extends Compatibility {
1926
1932
else
1927
1933
val deepPt = pt.deepenProto
1928
1934
deepPt match
1935
+ case pt @ FunProto (_, PolyProto (targs, resType)) =>
1936
+ // try to narrow further with snd argument list and following type params
1937
+ resolveMapped(candidates,
1938
+ skipParamClause(pt.typedArgs().tpes, targs.tpes), resType)
1929
1939
case pt @ FunProto (_, resType : FunOrPolyProto ) =>
1930
1940
// try to narrow further with snd argument list
1931
- resolveMapped(candidates, skipParamClause(pt.typedArgs().tpes), resType)
1941
+ resolveMapped(candidates,
1942
+ skipParamClause(pt.typedArgs().tpes, Nil ), resType)
1932
1943
case _ =>
1933
1944
// prefer alternatives that need no eta expansion
1934
1945
val noCurried = alts.filter(! resultIsMethod(_))
@@ -1974,7 +1985,7 @@ trait Applications extends Compatibility {
1974
1985
None
1975
1986
}
1976
1987
val mapped = reverseMapping.map(_._1)
1977
- overload.println(i " resolve mapped: $mapped" )
1988
+ overload.println(i " resolve mapped: ${ mapped.map(_.widen)} %, % with $pt " )
1978
1989
resolveOverloaded(mapped, pt).map(reverseMapping.toMap)
1979
1990
1980
1991
/** Try to typecheck any arguments in `pt` that are function values missing a
0 commit comments