斯卡拉 - 可implicitNotFound标注在方法级应用? [英] Scala - Can implicitNotFound annotation be applied at the method level?

查看:142
本文介绍了斯卡拉 - 可implicitNotFound标注在方法级应用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有需要与他们的隐观边界类型参数的方法。我可以使用@implicitNotFound注解给予更好的编译器错误时,该方法被称为无效的数据类型?

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?

该方法的文档是无用的,甚至源$ C ​​$ C没有帮助,和使用的所有例子都是在线的特征或一流水平。

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.

推荐答案

没有,你不能直接这样做。正如您所注意到, @implicitNotFound 诠释特质或类。你可以,但是,做一个特殊的隐式类型特地为该方法和注释,如果你真的想有一个自定义消息。

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.

这篇关于斯卡拉 - 可implicitNotFound标注在方法级应用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆