Back to Intellij Community

MapAwaitOnCollectionOfDeferred

plugins/kotlin/code-insight/descriptions/resources-en/inspectionDescriptions/MapAwaitOnCollectionOfDeferred.html

2025.3-rc-2520 B
Original Source

Reports map { it.await() } calls on collections of Deferred.

This can be replaced by a more concise and potentially more efficient awaitAll() call.

See the documentation for kotlinx.coroutines.awaitAll for more details.

Example:

suspend fun waitForResult(results: List<Deferred<String>>): List<String> {
    return results.map { it.await() }
  }

After the quick-fix is applied:

suspend fun waitForResult(results: List<Deferred<String>>): List<String> {
    return results.awaitAll()
  }