@@ -1927,35 +1927,40 @@ trait Applications extends Compatibility {
19271927 case _ => false
19281928
19291929 record(" resolveOverloaded.narrowedApplicable" , candidates.length)
1930- val found = narrowMostSpecific(candidates)
1931- if (found.length <= 1 ) found
1930+ if pt.isErroneous then
1931+ // `pt` might have become erroneous by typing arguments of FunProtos.
1932+ // If `pt` is erroneous, don't try to go further; report the error in `pt` instead.
1933+ candidates
19321934 else
1933- val deepPt = pt.deepenProto
1934- deepPt match
1935- case pt @ FunProto (_, resType : FunOrPolyProto ) =>
1936- // try to narrow further with snd argument list
1937- resolveMapped(candidates, skipParamClause(pt.typedArgs().tpes), resType)
1938- case _ =>
1939- // prefer alternatives that need no eta expansion
1940- val noCurried = alts.filter(! resultIsMethod(_))
1941- val noCurriedCount = noCurried.length
1942- if noCurriedCount == 1 then
1943- noCurried
1944- else if noCurriedCount > 1 && noCurriedCount < alts.length then
1945- resolveOverloaded1(noCurried, pt)
1946- else
1947- // prefer alternatves that match without default parameters
1948- val noDefaults = alts.filter(! _.symbol.hasDefaultParams)
1949- val noDefaultsCount = noDefaults.length
1950- if noDefaultsCount == 1 then
1951- noDefaults
1952- else if noDefaultsCount > 1 && noDefaultsCount < alts.length then
1953- resolveOverloaded1(noDefaults, pt)
1954- else if deepPt ne pt then
1955- // try again with a deeper known expected type
1956- resolveOverloaded1(alts, deepPt)
1935+ val found = narrowMostSpecific(candidates)
1936+ if found.length <= 1 then found
1937+ else
1938+ val deepPt = pt.deepenProto
1939+ deepPt match
1940+ case pt @ FunProto (_, resType : FunOrPolyProto ) =>
1941+ // try to narrow further with snd argument list
1942+ resolveMapped(candidates, skipParamClause(pt.typedArgs().tpes), resType)
1943+ case _ =>
1944+ // prefer alternatives that need no eta expansion
1945+ val noCurried = alts.filter(! resultIsMethod(_))
1946+ val noCurriedCount = noCurried.length
1947+ if noCurriedCount == 1 then
1948+ noCurried
1949+ else if noCurriedCount > 1 && noCurriedCount < alts.length then
1950+ resolveOverloaded1(noCurried, pt)
19571951 else
1958- candidates
1952+ // prefer alternatves that match without default parameters
1953+ val noDefaults = alts.filter(! _.symbol.hasDefaultParams)
1954+ val noDefaultsCount = noDefaults.length
1955+ if noDefaultsCount == 1 then
1956+ noDefaults
1957+ else if noDefaultsCount > 1 && noDefaultsCount < alts.length then
1958+ resolveOverloaded1(noDefaults, pt)
1959+ else if deepPt ne pt then
1960+ // try again with a deeper known expected type
1961+ resolveOverloaded1(alts, deepPt)
1962+ else
1963+ candidates
19591964 }
19601965 end resolveOverloaded1
19611966
0 commit comments