From e8f46bad289aae2d8c2fb06080cb019dbc82fa43 Mon Sep 17 00:00:00 2001
From: Eugene Flesselle <eugene@flesselle.net>
Date: Mon, 19 Feb 2024 17:36:34 +0100
Subject: [PATCH] Attempt implicit search for old style `implicit` parameters

(not only `using` params)

[Cherry-picked 1e890164b6dcb7d4f84a5df5135f56111ae74925]
---
 .../src/dotty/tools/dotc/typer/Applications.scala   |  2 +-
 tests/neg/i19594.check                              |  8 ++++++++
 tests/neg/i19594.scala                              | 13 +++++++++++++
 3 files changed, 22 insertions(+), 1 deletion(-)
 create mode 100644 tests/neg/i19594.check
 create mode 100644 tests/neg/i19594.scala

diff --git a/compiler/src/dotty/tools/dotc/typer/Applications.scala b/compiler/src/dotty/tools/dotc/typer/Applications.scala
index 99074313e8bb..e16645cb4190 100644
--- a/compiler/src/dotty/tools/dotc/typer/Applications.scala
+++ b/compiler/src/dotty/tools/dotc/typer/Applications.scala
@@ -620,7 +620,7 @@ trait Applications extends Compatibility {
               defaultArg.tpe.widen match
                 case _: MethodOrPoly if testOnly => matchArgs(args1, formals1, n + 1)
                 case _ => matchArgs(args1, addTyped(treeToArg(defaultArg)), n + 1)
-            else if methodType.isContextualMethod && ctx.mode.is(Mode.ImplicitsEnabled) then
+            else if methodType.isImplicitMethod && ctx.mode.is(Mode.ImplicitsEnabled) then
               matchArgs(args1, addTyped(treeToArg(implicitArg)), n + 1)
             else
               missingArg(n)
diff --git a/tests/neg/i19594.check b/tests/neg/i19594.check
new file mode 100644
index 000000000000..bb9ff3fc68af
--- /dev/null
+++ b/tests/neg/i19594.check
@@ -0,0 +1,8 @@
+-- [E172] Type Error: tests/neg/i19594.scala:12:14 ---------------------------------------------------------------------
+12 |  assertEquals(true, 1, "values are not the same") // error
+   |  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |  Can you see me?!
+-- [E172] Type Error: tests/neg/i19594.scala:13:14 ---------------------------------------------------------------------
+13 |  assertEquals(true, 1) // error
+   |  ^^^^^^^^^^^^^^^^^^^^^
+   |  Can you see me?!
diff --git a/tests/neg/i19594.scala b/tests/neg/i19594.scala
new file mode 100644
index 000000000000..a559da8d9250
--- /dev/null
+++ b/tests/neg/i19594.scala
@@ -0,0 +1,13 @@
+import scala.annotation.implicitNotFound
+
+@implicitNotFound("Can you see me?!")
+trait Compare[A, B]
+
+object example extends App:
+
+  // The presence of the below default argument prevents the `implicitNotFound` message from appearing
+  def assertEquals[A, B](a: A, b: B, clue: => Any = "values are not the same")
+                        (implicit comp: Compare[A, B]): Unit = ()
+
+  assertEquals(true, 1, "values are not the same") // error
+  assertEquals(true, 1) // error