Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scala - Can implicitNotFound annotation be applied at the method level?

I have a method that takes type parameters with an implicit view bounds on them. Can I use the @implicitNotFound annotation to give nicer compiler errors when the method is called with invalid data types?

The documentation for the method is useless and even the source code doesn't help, and all the examples of use online are at the trait or class level.

like image 480
Woodz Avatar asked Dec 12 '12 12:12

Woodz


1 Answers

No, you cannot directly do that. As you’ve noticed, @implicitNotFound annotates traits or classes. You could, however, make a special implicit type just for that method and annotate it if you really wanted to have a custom message.

like image 101
Jean-Philippe Pellet Avatar answered Sep 30 '22 05:09

Jean-Philippe Pellet