Skip to content

Commit c8af35c

Browse files
committed
Alternative (working) approach to binary compatibility for SubscriptionReceiveChannel
1 parent f5f0983 commit c8af35c

File tree

5 files changed

+7
-9
lines changed

5 files changed

+7
-9
lines changed

common/kotlinx-coroutines-core-common/src/main/kotlin/kotlinx/coroutines/experimental/Annotations.common.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
// user code that uses kotlinx.coroutines library otherwise, see https://youtrack.jetbrains.com/issue/KT-23727
1919
package kotlinx.coroutines.experimental.internalAnnotations
2020

21-
@Target(AnnotationTarget.FILE)
21+
@Target(AnnotationTarget.FILE, AnnotationTarget.FUNCTION)
2222
internal expect annotation class JvmName(val name: String)
2323

2424
@Target(AnnotationTarget.FILE)

common/kotlinx-coroutines-core-common/src/main/kotlin/kotlinx/coroutines/experimental/channels/ArrayBroadcastChannel.kt

-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ class ArrayBroadcastChannel<E>(
6868
override val isBufferAlwaysFull: Boolean get() = false
6969
override val isBufferFull: Boolean get() = size >= capacity
7070

71-
@Suppress("RETURN_TYPE_MISMATCH_ON_OVERRIDE")
7271
override fun openSubscription(): ReceiveChannel<E> =
7372
Subscriber(this).also {
7473
updateHead(addSub = it)

common/kotlinx-coroutines-core-common/src/main/kotlin/kotlinx/coroutines/experimental/channels/BroadcastChannel.kt

+4-5
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ package kotlinx.coroutines.experimental.channels
1919
import kotlinx.coroutines.experimental.*
2020
import kotlinx.coroutines.experimental.channels.Channel.Factory.CONFLATED
2121
import kotlinx.coroutines.experimental.channels.Channel.Factory.UNLIMITED
22-
import kotlinx.coroutines.experimental.internal.Closeable
22+
import kotlinx.coroutines.experimental.internal.*
2323
import kotlinx.coroutines.experimental.internalAnnotations.*
2424

2525
/**
@@ -49,16 +49,15 @@ public interface BroadcastChannel<E> : SendChannel<E> {
4949
* The resulting channel shall be [cancelled][ReceiveChannel.cancel] to unsubscribe from this
5050
* broadcast channel.
5151
*/
52-
@Suppress("CONFLICTING_OVERLOADS")
5352
public fun openSubscription(): ReceiveChannel<E>
5453

5554
/**
5655
* @suppress **Deprecated**: Return type changed to `ReceiveChannel`, this one left here for binary compatibility.
5756
*/
5857
@Deprecated(level = DeprecationLevel.HIDDEN, message = "Return type changed to `ReceiveChannel`, this one left here for binary compatibility")
59-
@Suppress("CONFLICTING_OVERLOADS")
60-
@JsName("openSubscriptionDeprecated")
61-
public fun openSubscription(): SubscriptionReceiveChannel<E> = openSubscription() as SubscriptionReceiveChannel<E>
58+
@JvmName("openSubscription")
59+
@Suppress("INAPPLICABLE_JVM_NAME")
60+
public fun openSubscription1(): SubscriptionReceiveChannel<E> = openSubscription() as SubscriptionReceiveChannel<E>
6261

6362
/**
6463
* @suppress **Deprecated**: Renamed to [openSubscription]

common/kotlinx-coroutines-core-common/src/main/kotlin/kotlinx/coroutines/experimental/channels/ConflatedBroadcastChannel.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public class ConflatedBroadcastChannel<E>() : BroadcastChannel<E> {
113113
override val isClosedForSend: Boolean get() = _state.value is Closed
114114
override val isFull: Boolean get() = false
115115

116-
@Suppress("UNCHECKED_CAST", "RETURN_TYPE_MISMATCH_ON_OVERRIDE")
116+
@Suppress("UNCHECKED_CAST")
117117
override fun openSubscription(): ReceiveChannel<E> {
118118
val subscriber = Subscriber<E>(this)
119119
_state.loop { state ->

js/kotlinx-coroutines-core-js/src/main/kotlin/kotlinx/coroutines/experimental/Annotations.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
package kotlinx.coroutines.experimental.internalAnnotations
1818

19-
@Target(AnnotationTarget.FILE)
19+
@Target(AnnotationTarget.FILE, AnnotationTarget.FUNCTION)
2020
internal actual annotation class JvmName(actual val name: String)
2121

2222
@Target(AnnotationTarget.FILE)

0 commit comments

Comments
 (0)