Skip to content

Commit cd65eb9

Browse files
authored
Attempt implicit search for old style implicit parameters in Application matchArgs (#19737)
Fixes #19594
2 parents 5e9e5e9 + 1e89016 commit cd65eb9

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ trait Applications extends Compatibility {
638638
defaultArg.tpe.widen match
639639
case _: MethodOrPoly if testOnly => matchArgs(args1, formals1, n + 1)
640640
case _ => matchArgs(args1, addTyped(treeToArg(defaultArg)), n + 1)
641-
else if methodType.isContextualMethod && ctx.mode.is(Mode.ImplicitsEnabled) then
641+
else if methodType.isImplicitMethod && ctx.mode.is(Mode.ImplicitsEnabled) then
642642
matchArgs(args1, addTyped(treeToArg(implicitArg)), n + 1)
643643
else
644644
missingArg(n)

tests/neg/i19594.check

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
-- [E172] Type Error: tests/neg/i19594.scala:12:14 ---------------------------------------------------------------------
2+
12 | assertEquals(true, 1, "values are not the same") // error
3+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4+
| Can you see me?!
5+
-- [E172] Type Error: tests/neg/i19594.scala:13:14 ---------------------------------------------------------------------
6+
13 | assertEquals(true, 1) // error
7+
| ^^^^^^^^^^^^^^^^^^^^^
8+
| Can you see me?!

tests/neg/i19594.scala

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import scala.annotation.implicitNotFound
2+
3+
@implicitNotFound("Can you see me?!")
4+
trait Compare[A, B]
5+
6+
object example extends App:
7+
8+
// The presence of the below default argument prevents the `implicitNotFound` message from appearing
9+
def assertEquals[A, B](a: A, b: B, clue: => Any = "values are not the same")
10+
(implicit comp: Compare[A, B]): Unit = ()
11+
12+
assertEquals(true, 1, "values are not the same") // error
13+
assertEquals(true, 1) // error

0 commit comments

Comments
 (0)