File tree 3 files changed +10
-6
lines changed
kotlinx-coroutines-jdk9/src
kotlinx-coroutines-reactive/src
3 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ import org.reactivestreams.FlowAdapters
33
33
* @throws IllegalArgumentException if the provided [context] contains a [Job] instance.
34
34
*/
35
35
@ExperimentalCoroutinesApi
36
- public fun <T > flowPublish (
36
+ public fun <T : Any > flowPublish (
37
37
context : CoroutineContext = EmptyCoroutineContext ,
38
38
@BuilderInference block : suspend ProducerScope <T >.() -> Unit
39
39
): Flow .Publisher <T > = FlowAdapters .toFlowPublisher(publish(context, block))
Original file line number Diff line number Diff line change 4
4
5
5
package kotlinx.coroutines.reactive
6
6
7
+ import kotlinx.coroutines.*
7
8
import kotlinx.coroutines.channels.*
8
9
import org.reactivestreams.*
9
10
import kotlin.coroutines.*
@@ -18,7 +19,10 @@ import kotlin.coroutines.*
18
19
@Deprecated(message = " Deprecated in the favour of consumeAsFlow()" ,
19
20
level = DeprecationLevel .WARNING , // Error in 1.4
20
21
replaceWith = ReplaceWith (" this.consumeAsFlow().asPublisher()" ))
21
- public fun <T > ReceiveChannel<T>.asPublisher (context : CoroutineContext = EmptyCoroutineContext ): Publisher <T > = publish(context) {
22
- for (t in this @asPublisher)
23
- send(t)
24
- }
22
+ public fun <T > ReceiveChannel<T>.asPublisher (context : CoroutineContext = EmptyCoroutineContext ): Publisher <T > =
23
+ // we call the deprecated version here because the non-deprecated one requires <T: Any> now
24
+ @Suppress(" DEPRECATION_ERROR" )
25
+ GlobalScope .publish(context) {
26
+ for (t in this @asPublisher)
27
+ send(t)
28
+ }
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ import kotlin.internal.*
37
37
* @throws IllegalArgumentException if the provided [context] contains a [Job] instance.
38
38
*/
39
39
@ExperimentalCoroutinesApi
40
- public fun <T > publish (
40
+ public fun <T : Any > publish (
41
41
context : CoroutineContext = EmptyCoroutineContext ,
42
42
@BuilderInference block : suspend ProducerScope <T >.() -> Unit
43
43
): Publisher <T > {
You can’t perform that action at this time.
0 commit comments