Skip to content
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

Improve message from inherited implicitNotFound #11653

Closed
som-snytt opened this issue Jul 29, 2019 · 2 comments · Fixed by scala/scala#8280
Closed

Improve message from inherited implicitNotFound #11653

som-snytt opened this issue Jul 29, 2019 · 2 comments · Fixed by scala/scala#8280

Comments

@som-snytt
Copy link

When using the annotation from a supertype, include the name of the required type in the error message.

Also,

scala> @annotation.implicitNotFound("Need one for ${A}")
     | trait T[A] ; trait U extends T[Int] ; implicitly[U] ; implicitly[T[String]]
       trait T[A] ; trait U extends T[Int] ; implicitly[U] ; implicitly[T[String]]
                                                       ^
On line 2: error: Need one for
       trait T[A] ; trait U extends T[Int] ; implicitly[U] ; implicitly[T[String]]
                                                                       ^
On line 2: error: Need one for String
@som-snytt
Copy link
Author

Noticed in fthomas/refined#661

@som-snytt
Copy link
Author

Lukas's good suggestion to refcheck if an annotation is missing was a bit too much work, but in future it could be enabled under Xlint:implicitNotFound.

Maybe the message change here can also be tweaked. It would be nice if the intersobralator accepted ${this} for the required type. It's not obvious that type args are helpful unless they match, so there are reasons not to include the annotation. I don't remember the original use case.

In future, warn if omitting the custom message because it intersobralates type args that don't match.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants