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

I have a method that accepts type parameters with implicit restrictions on them. Can I use the @implicitNotFound annotation to give more nice compiler errors when calling a method with invalid data types?

The documentation for the method is useless and even the source code does not help, and all examples of using online are at the level of attributes or classes.

+6
source share
1 answer

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

+4
source

All Articles