Skip to content

Commit 5fda17a

Browse files
committed
Fix "prefer not curried" criterion embedding
The previous code did not compose correctly with the "no defaults" criterion that followed.
1 parent 14e38e5 commit 5fda17a

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

compiler/src/dotty/tools/dotc/typer/Applications.scala

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1802,20 +1802,24 @@ trait Applications extends Compatibility {
18021802
case _ =>
18031803
// prefer alternatives that need no eta expansion
18041804
val noCurried = alts.filter(!resultIsMethod(_))
1805+
val noCurriedCount = noCurried.length
18051806
if noCurried.length == 1 then
18061807
noCurried
1808+
else if noCurriedCount > 1 && noCurriedCount < alts.length then
1809+
resolveOverloaded(noCurried, pt, targs)
18071810
else
18081811
// prefer alternatves that match without default parameters
1809-
val noDefaults = noCurried.filter(!_.symbol.hasDefaultParams)
1812+
val noDefaults = alts.filter(!_.symbol.hasDefaultParams)
18101813
val noDefaultsCount = noDefaults.length
18111814
if noDefaultsCount == 1 then
1812-
noDefaults // return unique alternative without default parameters if it exists
1815+
noDefaults
18131816
else if noDefaultsCount > 1 && noDefaultsCount < alts.length then
1814-
resolveOverloaded(noDefaults, pt, targs) // try again, dropping defult arguments
1817+
resolveOverloaded(noDefaults, pt, targs)
18151818
else if deepPt ne pt then
18161819
// try again with a deeper known expected type
18171820
resolveOverloaded(alts, deepPt, targs)
1818-
else candidates
1821+
else
1822+
candidates
18191823
end resolveOverloaded
18201824

18211825
/** Try to typecheck any arguments in `pt` that are function values missing a

0 commit comments

Comments
 (0)