Skip to content

Commit

Permalink
Alternative (working) approach to binary compatibility for Subscripti…
Browse files Browse the repository at this point in the history
…onReceiveChannel
  • Loading branch information
elizarov committed May 16, 2018
1 parent f5f0983 commit c8af35c
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// user code that uses kotlinx.coroutines library otherwise, see https://youtrack.jetbrains.com/issue/KT-23727
package kotlinx.coroutines.experimental.internalAnnotations

@Target(AnnotationTarget.FILE)
@Target(AnnotationTarget.FILE, AnnotationTarget.FUNCTION)
internal expect annotation class JvmName(val name: String)

@Target(AnnotationTarget.FILE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ class ArrayBroadcastChannel<E>(
override val isBufferAlwaysFull: Boolean get() = false
override val isBufferFull: Boolean get() = size >= capacity

@Suppress("RETURN_TYPE_MISMATCH_ON_OVERRIDE")
override fun openSubscription(): ReceiveChannel<E> =
Subscriber(this).also {
updateHead(addSub = it)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package kotlinx.coroutines.experimental.channels
import kotlinx.coroutines.experimental.*
import kotlinx.coroutines.experimental.channels.Channel.Factory.CONFLATED
import kotlinx.coroutines.experimental.channels.Channel.Factory.UNLIMITED
import kotlinx.coroutines.experimental.internal.Closeable
import kotlinx.coroutines.experimental.internal.*
import kotlinx.coroutines.experimental.internalAnnotations.*

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

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

/**
* @suppress **Deprecated**: Renamed to [openSubscription]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public class ConflatedBroadcastChannel<E>() : BroadcastChannel<E> {
override val isClosedForSend: Boolean get() = _state.value is Closed
override val isFull: Boolean get() = false

@Suppress("UNCHECKED_CAST", "RETURN_TYPE_MISMATCH_ON_OVERRIDE")
@Suppress("UNCHECKED_CAST")
override fun openSubscription(): ReceiveChannel<E> {
val subscriber = Subscriber<E>(this)
_state.loop { state ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package kotlinx.coroutines.experimental.internalAnnotations

@Target(AnnotationTarget.FILE)
@Target(AnnotationTarget.FILE, AnnotationTarget.FUNCTION)
internal actual annotation class JvmName(actual val name: String)

@Target(AnnotationTarget.FILE)
Expand Down

0 comments on commit c8af35c

Please sign in to comment.