Skip to content

Commit

Permalink
Add missing opt-ins for InternalForInheritanceCoroutinesApi (#4171)
Browse files Browse the repository at this point in the history
Should have no effect on the user code, just fixing the internal warnings.
  • Loading branch information
chaoren authored Jul 9, 2024
1 parent 0f4b546 commit 2d9f944
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ public fun <T> ListenableFuture<T>.asDeferred(): Deferred<T> {
cancel(false)
}
// Return hides the CompletableDeferred. This should prevent casting.
@OptIn(InternalForInheritanceCoroutinesApi::class)
return object : Deferred<T> by deferred {}
}

Expand Down
1 change: 1 addition & 0 deletions integration/kotlinx-coroutines-play-services/src/Tasks.kt
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ private fun <T> Task<T>.asDeferredImpl(cancellationTokenSource: CancellationToke
}
}
// Prevent casting to CompletableDeferred and manual completion.
@OptIn(InternalForInheritanceCoroutinesApi::class)
return object : Deferred<T> by deferred {}
}

Expand Down
2 changes: 2 additions & 0 deletions kotlinx-coroutines-core/common/test/AwaitTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ class AwaitTest : TestBase() {
fun testAwaitAllDelegates() = runTest {
expect(1)
val deferred = CompletableDeferred<String>()
@OptIn(InternalForInheritanceCoroutinesApi::class)
val delegate = object : Deferred<String> by deferred {}
launch {
expect(3)
Expand All @@ -367,6 +368,7 @@ class AwaitTest : TestBase() {
fun testCancelAwaitAllDelegate() = runTest {
expect(1)
val deferred = CompletableDeferred<String>()
@OptIn(InternalForInheritanceCoroutinesApi::class)
val delegate = object : Deferred<String> by deferred {}
launch {
expect(3)
Expand Down

0 comments on commit 2d9f944

Please sign in to comment.