是否有与 Scala 中的 SuppressWarnings 等效的东西? [英] Is there an equivalent to SuppressWarnings in Scala?

查看:63
本文介绍了是否有与 Scala 中的 SuppressWarnings 等效的东西?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道 scala 是否有相当于 java 的 @SuppressWarnings 可以应用于函数或任何忽略该函数发出的任何弃用警告[1]?

I was wondering if scala had an equivalent to java's @SuppressWarnings that can be applied to a function or whatever to ignore any deprecation warnings[1] that function emits?

1:在我的案例中的相关警告是:不推荐使用类 Thread 中的方法停止:有关更多信息,请参阅相应的 Javadoc. 我知道停止的问题,但仍有一些情况下对于遗留代码,我们必须使用它.

1: Relevant warning in my case is: method stop in class Thread is deprecated: see corresponding Javadoc for more information. I am aware of the problems with stop however there are still some cases where due to legacy code we have to use it.

推荐答案

否,针对此类功能的增强请求 [1] 已作为 wontfix 关闭.

No, and an enhancement request [1] for such a feature was closed as wontfix.

我同意这会很有用.我希望 Scala 核心团队不会反对这个想法,但他们的资源有限,而且有许多更高的优先级.

I agree it would be useful. I expect that the Scala core team aren't against the idea, but they have finite resources and many higher priorities.

更新:此功能最终在 2020 年 4 月 22 日的 Scala 2.13.2 版本中实现,请参阅 这个答案

update: this feature was eventually implemented in scala 2.13.2 release on 2020-04-22, see this answer

[1] https://issues.scala-lang.org/browse/SI-1781

这篇关于是否有与 Scala 中的 SuppressWarnings 等效的东西?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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