Skip to content

Commit

Permalink
Backport "Attempt implicit search for old style implicit parameters i…
Browse files Browse the repository at this point in the history
…n Application matchArgs"
  • Loading branch information
mzuehlke committed Apr 12, 2024
1 parent feeddb7 commit 875dd36
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/typer/Applications.scala
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,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)
Expand Down
8 changes: 8 additions & 0 deletions tests/neg/i19594.check
Original file line number Diff line number Diff line change
@@ -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?!
13 changes: 13 additions & 0 deletions tests/neg/i19594.scala
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 875dd36

Please sign in to comment.