Skip to content

Show tvar bounds in "no implicit argument" message #12233

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/typer/ErrorReporting.scala
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ class ImplicitSearchError(
}

private def defaultImplicitNotFoundMessage = {
em"no implicit argument of type $pt was found${location("for")}"
ex"no implicit argument of type $pt was found${location("for")}"
}

/** Construct a custom error message given an ambiguous implicit
Expand Down
12 changes: 12 additions & 0 deletions tests/neg/i12232.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
-- Error: tests/neg/i12232.scala:17:15 ---------------------------------------------------------------------------------
17 | foo(min(3, 4)) // error: works in Scala 2, not in 3
| ^
| no implicit argument of type Op[Int, Int, V] was found for parameter op of method min in object Foo
|
| where: V is a type variable with constraint <: Double
-- Error: tests/neg/i12232.scala:19:16 ---------------------------------------------------------------------------------
19 | foo(minR(3, 4)) // error: works in Scala 2, not in 3
| ^
| no implicit argument of type Op[Int, Int, R] was found for parameter op of method minR in object Foo
|
| where: R is a type variable with constraint <: Double
20 changes: 20 additions & 0 deletions tests/neg/i12232.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
trait Op[T1, T2, +R] {
def apply(t1: T1, t2: T2): R
}

object Op {
implicit val compInt: Op[Int, Int, Int] = new Op[Int, Int, Int] {
def apply(x: Int, y: Int) = scala.math.min(x, y)
}
}

object Foo {
def foo(x: Double) = x + 1.0
def min[T, U, V](x: T, y: U)(implicit op: Op[T, U, V]): V = op(x, y)
def minInt(x: Int, y: Int)(implicit op: Op[Int, Int, Int]): Int = op(x, y)
def minR[R](x: Int, y: Int)(implicit op: Op[Int, Int, R]): R = op(x, y)
min(3, 4) // works in both
foo(min(3, 4)) // error: works in Scala 2, not in 3
foo(minInt(3, 4)) // works in both
foo(minR(3, 4)) // error: works in Scala 2, not in 3
}
5 changes: 4 additions & 1 deletion tests/neg/i9568.check
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
-- Error: tests/neg/i9568.scala:13:10 ----------------------------------------------------------------------------------
13 | blaMonad.foo(bla) // error: diverges
| ^
| no implicit argument of type => Monad[F] was found for parameter ev of method blaMonad in object Test.
| no implicit argument of type => Monad[F] was found for parameter ev of method blaMonad in object Test
|
| where: F is a type variable with constraint <: [_] =>> Any
| .
| I found:
|
| Test.blaMonad[Nothing, S](Test.blaMonad[F, S])
Expand Down