Skip to content

Commit

Permalink
Backport "Attempt implicit search for old style implicit parameters…
Browse files Browse the repository at this point in the history
… in Application matchArgs" to LTS (#20936)

Backports #19737 to the LTS branch.

PR submitted by the release tooling.
[skip ci]
  • Loading branch information
WojciechMazur authored Jul 2, 2024
2 parents 2fbc51d + 4a1ea5f commit f0d74b7
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 @@ -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)
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 f0d74b7

Please sign in to comment.