Scala 异步和 Wartremover

Scala Async and Wartremover

我想使用 scala-async。 我还使用启用了 [Return] 的 Wartremover。 (http://www.wartremover.org/doc/warts.html#return).

然后我添加了一些代码来测试它:

async {
  val studentsCount = await(studentsDao.getStudents())
  val externalStudentsCount = await(studentsDao.getExternalStudents())

  externalStudentsCount + studentsCount
}

当我尝试编译它时,出现错误:

[wartremover:Return] return is disabled

有什么方法可以将 Wartremover 与 scala-async 一起使用吗?

似乎 async 宏在幕后生成了 return 语句。

您可以通过在 async 块上方添加 @SuppressWarnings(Array("org.wartremover.warts.Return")) 来解决它。