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

Open
som-snytt opened this issue Jul 29, 2019 · 2 comments

Comments

@som-snytt
Copy link

commented Jul 29, 2019

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

This comment has been minimized.

Copy link
Author

commented Jul 29, 2019

Noticed in fthomas/refined#661

@som-snytt

This comment has been minimized.

Copy link
Author

commented Jul 30, 2019

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
2 participants
You can’t perform that action at this time.