@@ -1945,35 +1945,40 @@ trait Applications extends Compatibility {
1945
1945
case _ => false
1946
1946
1947
1947
record(" resolveOverloaded.narrowedApplicable" , candidates.length)
1948
- val found = narrowMostSpecific(candidates)
1949
- if (found.length <= 1 ) found
1948
+ if pt.isErroneous then
1949
+ // `pt` might have become erroneous by typing arguments of FunProtos.
1950
+ // If `pt` is erroneous, don't try to go further; report the error in `pt` instead.
1951
+ candidates
1950
1952
else
1951
- val deepPt = pt.deepenProto
1952
- deepPt match
1953
- case pt @ FunProto (_, resType : FunProto ) =>
1954
- // try to narrow further with snd argument list
1955
- resolveMapped(candidates, skipParamClause(pt.typedArgs().tpes), resType)
1956
- case _ =>
1957
- // prefer alternatives that need no eta expansion
1958
- val noCurried = alts.filter(! resultIsMethod(_))
1959
- val noCurriedCount = noCurried.length
1960
- if noCurriedCount == 1 then
1961
- noCurried
1962
- else if noCurriedCount > 1 && noCurriedCount < alts.length then
1963
- resolveOverloaded1(noCurried, pt)
1964
- else
1965
- // prefer alternatves that match without default parameters
1966
- val noDefaults = alts.filter(! _.symbol.hasDefaultParams)
1967
- val noDefaultsCount = noDefaults.length
1968
- if noDefaultsCount == 1 then
1969
- noDefaults
1970
- else if noDefaultsCount > 1 && noDefaultsCount < alts.length then
1971
- resolveOverloaded1(noDefaults, pt)
1972
- else if deepPt ne pt then
1973
- // try again with a deeper known expected type
1974
- resolveOverloaded1(alts, deepPt)
1953
+ val found = narrowMostSpecific(candidates)
1954
+ if found.length <= 1 then found
1955
+ else
1956
+ val deepPt = pt.deepenProto
1957
+ deepPt match
1958
+ case pt @ FunProto (_, resType : FunProto ) =>
1959
+ // try to narrow further with snd argument list
1960
+ resolveMapped(candidates, skipParamClause(pt.typedArgs().tpes), resType)
1961
+ case _ =>
1962
+ // prefer alternatives that need no eta expansion
1963
+ val noCurried = alts.filter(! resultIsMethod(_))
1964
+ val noCurriedCount = noCurried.length
1965
+ if noCurriedCount == 1 then
1966
+ noCurried
1967
+ else if noCurriedCount > 1 && noCurriedCount < alts.length then
1968
+ resolveOverloaded1(noCurried, pt)
1975
1969
else
1976
- candidates
1970
+ // prefer alternatves that match without default parameters
1971
+ val noDefaults = alts.filter(! _.symbol.hasDefaultParams)
1972
+ val noDefaultsCount = noDefaults.length
1973
+ if noDefaultsCount == 1 then
1974
+ noDefaults
1975
+ else if noDefaultsCount > 1 && noDefaultsCount < alts.length then
1976
+ resolveOverloaded1(noDefaults, pt)
1977
+ else if deepPt ne pt then
1978
+ // try again with a deeper known expected type
1979
+ resolveOverloaded1(alts, deepPt)
1980
+ else
1981
+ candidates
1977
1982
}
1978
1983
end resolveOverloaded1
1979
1984
0 commit comments