android / codelab-kotlin-coroutines

Kotlin Coroutines codelab
Apache License 2.0
552 stars 268 forks source link

Creating a suspend function using suspendCancellableCoroutine -- doesn't compile #123

Closed Digipom closed 3 years ago

Digipom commented 3 years ago

The current code doesn't compile with suspendCancellableCoroutine and the code needs to be changed to suspendCoroutine:

suspend fun FusedLocationProviderClient.awaitLastLocation(): Location =
   suspendCancellableCoroutine<Location> { continuation ->
       lastLocation.addOnSuccessListener { location ->
           continuation.resume(location)
       }.addOnFailureListener { e ->
           continuation.resumeWithException(e)
       }
   }
wojtek-kalicinski commented 3 years ago

Cannot reproduce, the code from "step-06" folder compiles for me on a clean checkout and it matches the code you've shown.