scalascala-wartremover

Scala Async and Wartremover


I wanted to use scala-async. I also use Wartremover with [Return] enabled. (http://www.wartremover.org/doc/warts.html#return).

Then I added some code to test it:

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

  externalStudentsCount + studentsCount
}

When I try to compile it, it gives me error:

[wartremover:Return] return is disabled

Is there any way to use Wartremover with scala-async?


Solution

  • Seems that the async macro generates return statement under the hood.

    You can workaround it by adding @SuppressWarnings(Array("org.wartremover.warts.Return")) above the async block.