Skip to content

Fix #10603: implicitNotFound message for T <: Function1[_, _] #10611

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
Dec 3, 2020
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: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/typer/ErrorReporting.scala
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,8 @@ class ImplicitSearchError(
*/
private def userDefinedImplicitNotFoundTypeMessage: Option[String] =
pt.baseClasses.iterator
// Don't inherit "No implicit view available..." message if subtypes of Function1 are not treated as implicit conversions anymore
.filter(sym => Feature.migrateTo3 || sym != defn.Function1)
.map(userDefinedImplicitNotFoundTypeMessage(_))
.find(_.isDefined).flatten

Expand Down
4 changes: 4 additions & 0 deletions tests/neg/i10603a.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- Error: tests/neg/i10603a.scala:2:35 ---------------------------------------------------------------------------------
2 | val x = implicitly[List[Boolean]] // error
| ^
| no implicit argument of type List[Boolean] was found for parameter e of method implicitly in object Predef
3 changes: 3 additions & 0 deletions tests/neg/i10603a.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
object Test {
val x = implicitly[List[Boolean]] // error
}
4 changes: 4 additions & 0 deletions tests/neg/i10603b.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- Error: tests/neg/i10603b.scala:4:35 ---------------------------------------------------------------------------------
4 | val x = implicitly[List[Boolean]] // error
| ^
| No implicit view available from Int => Boolean.
5 changes: 5 additions & 0 deletions tests/neg/i10603b.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import language.`3.0-migration`

object Test {
val x = implicitly[List[Boolean]] // error
}
2 changes: 1 addition & 1 deletion tests/neg/summon-function.check
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- Error: tests/neg/summon-function.scala:2:23 -------------------------------------------------------------------------
2 | summon[Int => String] // error
| ^
| No implicit view available from Int => String.
| no implicit argument of type Int => String was found for parameter x of method summon in object Predef