Scala Async and Wartremover

887 views Asked by At

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?

1

There are 1 answers

5
simpadjo On BEST ANSWER

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.