diff --git a/compiler/src/dotty/tools/dotc/typer/Applications.scala b/compiler/src/dotty/tools/dotc/typer/Applications.scala index 49a124823534..e23d605641a9 100644 --- a/compiler/src/dotty/tools/dotc/typer/Applications.scala +++ b/compiler/src/dotty/tools/dotc/typer/Applications.scala @@ -1721,11 +1721,15 @@ trait Applications extends Compatibility { self: Typer with Dynamic => .map(advanced.toMap) // map surviving result(s) back to original candidates case _ => val noDefaults = alts.filter(!_.symbol.hasDefaultParams) - if (noDefaults.length == 1) noDefaults // return unique alternative without default parameters if it exists + val noDefaultsCount = noDefaults.length + if (noDefaultsCount == 1) + noDefaults // return unique alternative without default parameters if it exists + else if (noDefaultsCount > 1 && noDefaultsCount < alts.length) + resolveOverloaded(noDefaults, pt, targs) // try again, dropping defult arguments else { val deepPt = pt.deepenProto if (deepPt ne pt) resolveOverloaded(alts, deepPt, targs) - else alts + else candidates } } } diff --git a/tests/pos/i7082.scala b/tests/pos/i7082.scala new file mode 100644 index 000000000000..a7d5ec572cb9 --- /dev/null +++ b/tests/pos/i7082.scala @@ -0,0 +1,11 @@ +object Overloads { + + def foo[V](x: Int = 0, y: Int = 0, z: Int = 0): Nothing = ??? + + def foo[V](x: Int, y: Int): Nothing = ??? + + def foo[V](x: Int): Nothing = ??? + + foo(1) + +} \ No newline at end of file