Skip to content

Turn mismatch given errors into given not found errors #8607

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

Closed
Closed
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
8 changes: 3 additions & 5 deletions compiler/src/dotty/tools/dotc/typer/Implicits.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1407,11 +1407,9 @@ trait Implicits { self: Typer =>
}
if (ctx.reporter.hasErrors) {
ctx.reporter.removeBufferedMessages
SearchFailure {
adapted.tpe match {
case _: SearchFailureType => adapted
case _ => adapted.withType(new MismatchedImplicit(ref, pt, argument))
}
adapted.tpe match {
case _: SearchFailureType => SearchFailure(adapted)
case _ => NoMatchingImplicitsFailure
}
}
else {
Expand Down
13 changes: 13 additions & 0 deletions tests/neg/implicitSearch.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
-- Error: tests/neg/implicitSearch.scala:13:12 -------------------------------------------------------------------------
13 | sort(xs) // error (with a partially constructed implicit argument shown)
| ^
| no implicit argument of type Test.Ord[List[List[T]]] was found for parameter o of method sort in object Test.
| I found:
|
| Test.listOrd[T](Test.listOrd[T](/* missing */implicitly[Test.Ord[T]]))
|
| But no implicit values were found that match type Test.Ord[T].
-- Error: tests/neg/implicitSearch.scala:15:38 -------------------------------------------------------------------------
15 | listOrd(listOrd(implicitly[Ord[T]] /*not found*/)) // error
| ^
| no implicit argument of type Test.Ord[T] was found for parameter ev of method implicitly in object DottyPredef
2 changes: 0 additions & 2 deletions tests/neg/implicitSearch.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
object Test {

type T = String

class Ord[T]
implicit def listOrd[T](implicit o: Ord[T]): Ord[List[T]] = ???
implicit def intOrd: Ord[Int] = ???
Expand Down
18 changes: 18 additions & 0 deletions tests/neg/missing-implicit3.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
-- Error: tests/neg/missing-implicit3.scala:3:37 -----------------------------------------------------------------------
3 |val sortedFoos = List(new Foo).sorted // error
| ^
| No implicit Ordering defined for B
|
| where: B is a type variable with constraint >: Foo
| ..
| I found:
|
| scala.math.Ordering.ordered[A](/* missing */implicitly[scala.math.Ordering.AsComparable[B]])
|
| But no implicit values were found that match type scala.math.Ordering.AsComparable[B].
|
| One of the following imports might make progress towards fixing the problem:
|
| import math.Ordering.comparatorToOrdering
| import math.Ordering.ordered
|
3 changes: 3 additions & 0 deletions tests/neg/missing-implicit3.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Foo

val sortedFoos = List(new Foo).sorted // error
14 changes: 2 additions & 12 deletions tests/neg/subtyping.check
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
-- Error: tests/neg/subtyping.scala:8:27 -------------------------------------------------------------------------------
8 | implicitly[B#X <:< A#X] // error: no implicit argument
| ^
| Cannot prove that B#X <:< A#X..
| I found:
|
| <:<.refl[Nothing]
|
| But method refl in object <:< does not match type B#X <:< A#X.
| Cannot prove that B#X <:< A#X.
-- Error: tests/neg/subtyping.scala:12:27 ------------------------------------------------------------------------------
12 | implicitly[a.T <:< a.U] // error: no implicit argument
| ^
| Cannot prove that a.T <:< a.U..
| I found:
|
| <:<.refl[Nothing]
|
| But method refl in object <:< does not match type a.T <:< a.U.
| Cannot prove that a.T <:< a.U.
4 changes: 4 additions & 0 deletions tests/neg/summon-function.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- Error: tests/neg/summon-function.scala:2:23 -------------------------------------------------------------------------
2 | summon[Int => String] // error
| ^
| No implicit view available from Int => String.
3 changes: 3 additions & 0 deletions tests/neg/summon-function.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
object Test {
summon[Int => String] // error
}