Skip to content

Commit edfb179

Browse files
authored
Merge pull request #10611 from prolativ/no-implicit-view-message
Fix #10603: implicitNotFound message for T <: Function1[_, _] Don't display "No implicit view available ..." message when an given instance of a subtype of Function1 was not found
2 parents 04737b5 + 84b0627 commit edfb179

File tree

6 files changed

+19
-1
lines changed

6 files changed

+19
-1
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,8 @@ class ImplicitSearchError(
334334
*/
335335
private def userDefinedImplicitNotFoundTypeMessage: Option[String] =
336336
pt.baseClasses.iterator
337+
// Don't inherit "No implicit view available..." message if subtypes of Function1 are not treated as implicit conversions anymore
338+
.filter(sym => Feature.migrateTo3 || sym != defn.Function1)
337339
.map(userDefinedImplicitNotFoundTypeMessage(_))
338340
.find(_.isDefined).flatten
339341

tests/neg/i10603a.check

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-- Error: tests/neg/i10603a.scala:2:35 ---------------------------------------------------------------------------------
2+
2 | val x = implicitly[List[Boolean]] // error
3+
| ^
4+
| no implicit argument of type List[Boolean] was found for parameter e of method implicitly in object Predef

tests/neg/i10603a.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
object Test {
2+
val x = implicitly[List[Boolean]] // error
3+
}

tests/neg/i10603b.check

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-- Error: tests/neg/i10603b.scala:4:35 ---------------------------------------------------------------------------------
2+
4 | val x = implicitly[List[Boolean]] // error
3+
| ^
4+
| No implicit view available from Int => Boolean.

tests/neg/i10603b.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import language.`3.0-migration`
2+
3+
object Test {
4+
val x = implicitly[List[Boolean]] // error
5+
}

tests/neg/summon-function.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
-- Error: tests/neg/summon-function.scala:2:23 -------------------------------------------------------------------------
22
2 | summon[Int => String] // error
33
| ^
4-
| No implicit view available from Int => String.
4+
| no implicit argument of type Int => String was found for parameter x of method summon in object Predef

0 commit comments

Comments
 (0)