From 6ff32d683c0018a7458aa64ade3116c83024b8b6 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 12 Feb 2018 14:41:21 +0100 Subject: [PATCH] Fix #3930: Handle multiple type arguments in overloading resolution The error message for the neg case is a bit weird, (it complains about an ambiguity error), but improving it would require considerable complications, which I don't think are worth it at the present time. --- compiler/src/dotty/tools/dotc/typer/Applications.scala | 3 +-- tests/neg/i3930.scala | 7 +++++++ tests/run/i3930.scala | 8 ++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 tests/neg/i3930.scala create mode 100644 tests/run/i3930.scala diff --git a/compiler/src/dotty/tools/dotc/typer/Applications.scala b/compiler/src/dotty/tools/dotc/typer/Applications.scala index 155893ad6573..b87f97e53e66 100644 --- a/compiler/src/dotty/tools/dotc/typer/Applications.scala +++ b/compiler/src/dotty/tools/dotc/typer/Applications.scala @@ -1388,8 +1388,7 @@ trait Applications extends Compatibility { self: Typer with Dynamic => } } - case pt @ PolyProto(targs1, pt1) => - assert(targs.isEmpty) + case pt @ PolyProto(targs1, pt1) if targs.isEmpty => val alts1 = alts filter pt.isMatchedBy resolveOverloaded(alts1, pt1, targs1) diff --git a/tests/neg/i3930.scala b/tests/neg/i3930.scala new file mode 100644 index 000000000000..46a5abb95f5a --- /dev/null +++ b/tests/neg/i3930.scala @@ -0,0 +1,7 @@ +object A { + def a[F](x: Int) = 0 + def a[F](x: String) = 0 +} +object Test extends App { + A.a[String][Int](3) == 1 // error: ambiguous +} diff --git a/tests/run/i3930.scala b/tests/run/i3930.scala new file mode 100644 index 000000000000..99b8eeede4bd --- /dev/null +++ b/tests/run/i3930.scala @@ -0,0 +1,8 @@ +class Apply { def apply[A](x: Int) = 1 } +object A { + def a[F] = new Apply + def a[F](x: String) = 0 +} +object Test extends App { + assert(A.a[String][Int](3) == 1) +}