Skip to content

Commit ee96970

Browse files
authored
Merge pull request #12233 from dotty-staging/fix-12232
Show tvar bounds in "no implicit argument" message
2 parents 94342e1 + 68bc2d5 commit ee96970

File tree

4 files changed

+37
-2
lines changed

4 files changed

+37
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ class ImplicitSearchError(
315315
}
316316

317317
private def defaultImplicitNotFoundMessage = {
318-
em"no implicit argument of type $pt was found${location("for")}"
318+
ex"no implicit argument of type $pt was found${location("for")}"
319319
}
320320

321321
/** Construct a custom error message given an ambiguous implicit

tests/neg/i12232.check

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
-- Error: tests/neg/i12232.scala:17:15 ---------------------------------------------------------------------------------
2+
17 | foo(min(3, 4)) // error: works in Scala 2, not in 3
3+
| ^
4+
| no implicit argument of type Op[Int, Int, V] was found for parameter op of method min in object Foo
5+
|
6+
| where: V is a type variable with constraint <: Double
7+
-- Error: tests/neg/i12232.scala:19:16 ---------------------------------------------------------------------------------
8+
19 | foo(minR(3, 4)) // error: works in Scala 2, not in 3
9+
| ^
10+
| no implicit argument of type Op[Int, Int, R] was found for parameter op of method minR in object Foo
11+
|
12+
| where: R is a type variable with constraint <: Double

tests/neg/i12232.scala

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
trait Op[T1, T2, +R] {
2+
def apply(t1: T1, t2: T2): R
3+
}
4+
5+
object Op {
6+
implicit val compInt: Op[Int, Int, Int] = new Op[Int, Int, Int] {
7+
def apply(x: Int, y: Int) = scala.math.min(x, y)
8+
}
9+
}
10+
11+
object Foo {
12+
def foo(x: Double) = x + 1.0
13+
def min[T, U, V](x: T, y: U)(implicit op: Op[T, U, V]): V = op(x, y)
14+
def minInt(x: Int, y: Int)(implicit op: Op[Int, Int, Int]): Int = op(x, y)
15+
def minR[R](x: Int, y: Int)(implicit op: Op[Int, Int, R]): R = op(x, y)
16+
min(3, 4) // works in both
17+
foo(min(3, 4)) // error: works in Scala 2, not in 3
18+
foo(minInt(3, 4)) // works in both
19+
foo(minR(3, 4)) // error: works in Scala 2, not in 3
20+
}

tests/neg/i9568.check

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
-- Error: tests/neg/i9568.scala:13:10 ----------------------------------------------------------------------------------
22
13 | blaMonad.foo(bla) // error: diverges
33
| ^
4-
| no implicit argument of type => Monad[F] was found for parameter ev of method blaMonad in object Test.
4+
| no implicit argument of type => Monad[F] was found for parameter ev of method blaMonad in object Test
5+
|
6+
| where: F is a type variable with constraint <: [_] =>> Any
7+
| .
58
| I found:
69
|
710
| Test.blaMonad[Nothing, S](Test.blaMonad[F, S])

0 commit comments

Comments
 (0)