Skip to content

Commit

Permalink
Merge pull request #238 from ReactiveX/3.x-new-type-inference
Browse files Browse the repository at this point in the history
Handle new type inference algorithm
  • Loading branch information
vpriscan authored Sep 1, 2020
2 parents f22c013 + 7fcf3d3 commit 3e21313
Show file tree
Hide file tree
Showing 6 changed files with 187 additions and 4 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,10 @@ Learn more about building this project with JitPack [here](https://jitpack.io/#R



## SAM Helpers
## SAM Helpers (made obsolete since Kotlin 1.4)

_These methods have been made obsolete with new type inference algorithm in Kotlin 1.4.
They will be removed in some future RxKotlin version._

To help cope with the [SAM ambiguity issue](https://youtrack.jetbrains.com/issue/KT-14984) when using RxJava with Kotlin, there are a number of helper factories and extension functions to workaround the affected operators.

Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ buildscript {

plugins {
id("java-library")
kotlin("jvm") version "1.3.40"
kotlin("jvm") version "1.4.0"
id("org.jetbrains.dokka") version "0.9.18"
id("maven-publish")
id("com.jfrog.bintray") version "1.8.4"
Expand Down
64 changes: 63 additions & 1 deletion src/main/kotlin/io/reactivex/rxjava3/kotlin/Flowables.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import org.reactivestreams.Publisher

object Flowables {

@Deprecated("New type inference algorithm in Kotlin 1.4 makes this method obsolete. Method will be removed in future RxKotlin release.",
replaceWith = ReplaceWith("Flowable.combineLatest(source1, source2, combineFunction)", "io.reactivex.Flowable"),
level = DeprecationLevel.WARNING)
@CheckReturnValue
@BackpressureSupport(BackpressureKind.FULL)
@SchedulerSupport(SchedulerSupport.NONE)
Expand All @@ -38,6 +41,9 @@ object Flowables {
BiFunction<T1, T2, Pair<T1, T2>> { t1, t2 -> t1 to t2 })


@Deprecated("New type inference algorithm in Kotlin 1.4 makes this method obsolete. Method will be removed in future RxKotlin release.",
replaceWith = ReplaceWith("Flowable.combineLatest(source1, source2, source3, combineFunction)", "io.reactivex.Flowable"),
level = DeprecationLevel.WARNING)
@CheckReturnValue
@BackpressureSupport(BackpressureKind.FULL)
@SchedulerSupport(SchedulerSupport.NONE)
Expand All @@ -63,6 +69,9 @@ object Flowables {
Function3<T1, T2, T3, Triple<T1, T2, T3>> { t1, t2, t3 -> Triple(t1, t2, t3) })


@Deprecated("New type inference algorithm in Kotlin 1.4 makes this method obsolete. Method will be removed in future RxKotlin release.",
replaceWith = ReplaceWith("Flowable.combineLatest(source1, source2, source3, source4, combineFunction)", "io.reactivex.Flowable"),
level = DeprecationLevel.WARNING)
@CheckReturnValue
@BackpressureSupport(BackpressureKind.FULL)
@SchedulerSupport(SchedulerSupport.NONE)
Expand All @@ -76,6 +85,9 @@ object Flowables {
Function4 { t1: T1, t2: T2, t3: T3, t4: T4 -> combineFunction(t1, t2, t3, t4) })


@Deprecated("New type inference algorithm in Kotlin 1.4 makes this method obsolete. Method will be removed in future RxKotlin release.",
replaceWith = ReplaceWith("Flowable.combineLatest(source1, source2, source3, source4, source5, combineFunction)", "io.reactivex.Flowable"),
level = DeprecationLevel.WARNING)
@CheckReturnValue
@BackpressureSupport(BackpressureKind.FULL)
@SchedulerSupport(SchedulerSupport.NONE)
Expand All @@ -90,6 +102,9 @@ object Flowables {
Function5 { t1: T1, t2: T2, t3: T3, t4: T4, t5: T5 -> combineFunction(t1, t2, t3, t4, t5) })


@Deprecated("New type inference algorithm in Kotlin 1.4 makes this method obsolete. Method will be removed in future RxKotlin release.",
replaceWith = ReplaceWith("Flowable.combineLatest(source1, source2, source3, source4, source5, source6, combineFunction)", "io.reactivex.Flowable"),
level = DeprecationLevel.WARNING)
@CheckReturnValue
@BackpressureSupport(BackpressureKind.FULL)
@SchedulerSupport(SchedulerSupport.NONE)
Expand All @@ -104,6 +119,9 @@ object Flowables {
): Flowable<R> = Flowable.combineLatest(source1, source2, source3, source4, source5, source6,
Function6 { t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6 -> combineFunction(t1, t2, t3, t4, t5, t6) })

@Deprecated("New type inference algorithm in Kotlin 1.4 makes this method obsolete. Method will be removed in future RxKotlin release.",
replaceWith = ReplaceWith("Flowable.combineLatest(source1, source2, source3, source4, source5, source6, source7, combineFunction)", "io.reactivex.Flowable"),
level = DeprecationLevel.WARNING)
@CheckReturnValue
@BackpressureSupport(BackpressureKind.FULL)
@SchedulerSupport(SchedulerSupport.NONE)
Expand All @@ -120,6 +138,9 @@ object Flowables {
Function7 { t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6, t7: T7 -> combineFunction(t1, t2, t3, t4, t5, t6, t7) })


@Deprecated("New type inference algorithm in Kotlin 1.4 makes this method obsolete. Method will be removed in future RxKotlin release.",
replaceWith = ReplaceWith("Flowable.combineLatest(source1, source2, source3, source4, source5, source6, source7, source8, combineFunction)", "io.reactivex.Flowable"),
level = DeprecationLevel.WARNING)
@CheckReturnValue
@BackpressureSupport(BackpressureKind.FULL)
@SchedulerSupport(SchedulerSupport.NONE)
Expand All @@ -136,6 +157,9 @@ object Flowables {
): Flowable<R> = Flowable.combineLatest(source1, source2, source3, source4, source5, source6, source7, source8,
Function8 { t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6, t7: T7, t8: T8 -> combineFunction(t1, t2, t3, t4, t5, t6, t7, t8) })

@Deprecated("New type inference algorithm in Kotlin 1.4 makes this method obsolete. Method will be removed in future RxKotlin release.",
replaceWith = ReplaceWith("Flowable.combineLatest(source1, source2, source3, source4, source5, source6, source7, source8, source9, combineFunction)", "io.reactivex.Flowable"),
level = DeprecationLevel.WARNING)
@CheckReturnValue
@BackpressureSupport(BackpressureKind.FULL)
@SchedulerSupport(SchedulerSupport.NONE)
Expand All @@ -162,7 +186,9 @@ object Flowables {
crossinline source: (FlowableEmitter<T>) -> Unit
): Flowable<T> = Flowable.create({ source(it) }, mode)


@Deprecated("New type inference algorithm in Kotlin 1.4 makes this method obsolete. Method will be removed in future RxKotlin release.",
replaceWith = ReplaceWith("Flowable.zip(source1, source2, combineFunction)", "io.reactivex.Flowable"),
level = DeprecationLevel.WARNING)
@CheckReturnValue
@BackpressureSupport(BackpressureKind.FULL)
@SchedulerSupport(SchedulerSupport.NONE)
Expand All @@ -183,6 +209,9 @@ object Flowables {
Flowable.zip(source1, source2, BiFunction<T1, T2, Pair<T1, T2>> { t1, t2 -> t1 to t2 })


@Deprecated("New type inference algorithm in Kotlin 1.4 makes this method obsolete. Method will be removed in future RxKotlin release.",
replaceWith = ReplaceWith("Flowable.zip(source1, source2, source3, combineFunction)", "io.reactivex.Flowable"),
level = DeprecationLevel.WARNING)
@CheckReturnValue
@BackpressureSupport(BackpressureKind.FULL)
@SchedulerSupport(SchedulerSupport.NONE)
Expand All @@ -207,6 +236,9 @@ object Flowables {
): Flowable<Triple<T1, T2, T3>> = Flowable.zip(source1, source2, source3,
Function3<T1, T2, T3, Triple<T1, T2, T3>> { t1, t2, t3 -> Triple(t1, t2, t3) })

@Deprecated("New type inference algorithm in Kotlin 1.4 makes this method obsolete. Method will be removed in future RxKotlin release.",
replaceWith = ReplaceWith("Flowable.zip(source1, source2, source3, source4, combineFunction)", "io.reactivex.Flowable"),
level = DeprecationLevel.WARNING)
@CheckReturnValue
@BackpressureSupport(BackpressureKind.FULL)
@SchedulerSupport(SchedulerSupport.NONE)
Expand All @@ -219,6 +251,9 @@ object Flowables {
): Flowable<R> = Flowable.zip(source1, source2, source3, source4,
Function4 { t1: T1, t2: T2, t3: T3, t4: T4 -> combineFunction(t1, t2, t3, t4) })

@Deprecated("New type inference algorithm in Kotlin 1.4 makes this method obsolete. Method will be removed in future RxKotlin release.",
replaceWith = ReplaceWith("Flowable.zip(source1, source2, source3, source4, source5, combineFunction)", "io.reactivex.Flowable"),
level = DeprecationLevel.WARNING)
@CheckReturnValue
@BackpressureSupport(BackpressureKind.FULL)
@SchedulerSupport(SchedulerSupport.NONE)
Expand All @@ -230,6 +265,9 @@ object Flowables {
Function5 { t1: T1, t2: T2, t3: T3, t4: T4, t5: T5 -> combineFunction(t1, t2, t3, t4, t5) })


@Deprecated("New type inference algorithm in Kotlin 1.4 makes this method obsolete. Method will be removed in future RxKotlin release.",
replaceWith = ReplaceWith("Flowable.zip(source1, source2, source3, source4, source5, source6, combineFunction)", "io.reactivex.Flowable"),
level = DeprecationLevel.WARNING)
@CheckReturnValue
@BackpressureSupport(BackpressureKind.FULL)
@SchedulerSupport(SchedulerSupport.NONE)
Expand All @@ -240,6 +278,9 @@ object Flowables {
): Flowable<R> = Flowable.zip(source1, source2, source3, source4, source5, source6,
Function6 { t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6 -> combineFunction(t1, t2, t3, t4, t5, t6) })

@Deprecated("New type inference algorithm in Kotlin 1.4 makes this method obsolete. Method will be removed in future RxKotlin release.",
replaceWith = ReplaceWith("Flowable.zip(source1, source2, source3, source4, source5, source6, source7, combineFunction)", "io.reactivex.Flowable"),
level = DeprecationLevel.WARNING)
@CheckReturnValue
@BackpressureSupport(BackpressureKind.FULL)
@SchedulerSupport(SchedulerSupport.NONE)
Expand All @@ -252,6 +293,9 @@ object Flowables {
Function7 { t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6, t7: T7 -> combineFunction(t1, t2, t3, t4, t5, t6, t7) })


@Deprecated("New type inference algorithm in Kotlin 1.4 makes this method obsolete. Method will be removed in future RxKotlin release.",
replaceWith = ReplaceWith("Flowable.zip(source1, source2, source3, source4, source5, source6, source7, source8, combineFunction)", "io.reactivex.Flowable"),
level = DeprecationLevel.WARNING)
@CheckReturnValue
@BackpressureSupport(BackpressureKind.FULL)
@SchedulerSupport(SchedulerSupport.NONE)
Expand All @@ -264,6 +308,9 @@ object Flowables {
): Flowable<R> = Flowable.zip(source1, source2, source3, source4, source5, source6, source7, source8,
Function8 { t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6, t7: T7, t8: T8 -> combineFunction(t1, t2, t3, t4, t5, t6, t7, t8) })

@Deprecated("New type inference algorithm in Kotlin 1.4 makes this method obsolete. Method will be removed in future RxKotlin release.",
replaceWith = ReplaceWith("Flowable.zip(source1, source2, source3, source4, source5, source6, source7, source8, source9, combineFunction)", "io.reactivex.Flowable"),
level = DeprecationLevel.WARNING)
@CheckReturnValue
@BackpressureSupport(BackpressureKind.FULL)
@SchedulerSupport(SchedulerSupport.NONE)
Expand All @@ -286,6 +333,9 @@ object Flowables {
/**
* An alias to [Flowable.withLatestFrom], but allowing for cleaner lambda syntax.
*/
@Deprecated("New type inference algorithm in Kotlin 1.4 makes this method obsolete. Method will be removed in future RxKotlin release.",
replaceWith = ReplaceWith("withLatestFrom(other, combiner)"),
level = DeprecationLevel.WARNING)
@CheckReturnValue
@BackpressureSupport(BackpressureKind.PASS_THROUGH)
@SchedulerSupport(SchedulerSupport.NONE)
Expand All @@ -304,6 +354,9 @@ fun <T : Any, U : Any> Flowable<T>.withLatestFrom(other: Publisher<U>): Flowable
/**
* An alias to [Flowable.withLatestFrom], but allowing for cleaner lambda syntax.
*/
@Deprecated("New type inference algorithm in Kotlin 1.4 makes this method obsolete. Method will be removed in future RxKotlin release.",
replaceWith = ReplaceWith("withLatestFrom(o1, o2, combiner)"),
level = DeprecationLevel.WARNING)
@CheckReturnValue
@BackpressureSupport(BackpressureKind.PASS_THROUGH)
@SchedulerSupport(SchedulerSupport.NONE)
Expand All @@ -324,6 +377,9 @@ fun <T : Any, T1 : Any, T2 : Any> Flowable<T>.withLatestFrom(
/**
* An alias to [Flowable.withLatestFrom], but allowing for cleaner lambda syntax.
*/
@Deprecated("New type inference algorithm in Kotlin 1.4 makes this method obsolete. Method will be removed in future RxKotlin release.",
replaceWith = ReplaceWith("withLatestFrom(o1, o2, o3, combiner)"),
level = DeprecationLevel.WARNING)
@CheckReturnValue
@BackpressureSupport(BackpressureKind.PASS_THROUGH)
@SchedulerSupport(SchedulerSupport.NONE)
Expand All @@ -337,6 +393,9 @@ inline fun <T : Any, T1 : Any, T2 : Any, T3 : Any, R : Any> Flowable<T>.withLate
/**
* An alias to [Flowable.withLatestFrom], but allowing for cleaner lambda syntax.
*/
@Deprecated("New type inference algorithm in Kotlin 1.4 makes this method obsolete. Method will be removed in future RxKotlin release.",
replaceWith = ReplaceWith("withLatestFrom(o1, o2, o3, o4, combiner)"),
level = DeprecationLevel.WARNING)
@CheckReturnValue
@BackpressureSupport(BackpressureKind.FULL)
@SchedulerSupport(SchedulerSupport.NONE)
Expand All @@ -351,6 +410,9 @@ inline fun <T : Any, T1 : Any, T2 : Any, T3 : Any, T4 : Any, R : Any> Flowable<T
/**
* An alias to [Flowable.zipWith], but allowing for cleaner lambda syntax.
*/
@Deprecated("New type inference algorithm in Kotlin 1.4 makes this method obsolete. Method will be removed in future RxKotlin release.",
replaceWith = ReplaceWith("zipWith(other, zipper)"),
level = DeprecationLevel.WARNING)
@CheckReturnValue
@BackpressureSupport(BackpressureKind.PASS_THROUGH)
@SchedulerSupport(SchedulerSupport.NONE)
Expand Down
28 changes: 28 additions & 0 deletions src/main/kotlin/io/reactivex/rxjava3/kotlin/Maybes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import io.reactivex.rxjava3.core.MaybeSource
import io.reactivex.rxjava3.functions.*

object Maybes {

@Deprecated("New type inference algorithm in Kotlin 1.4 makes this method obsolete. Method will be removed in future RxKotlin release.",
replaceWith = ReplaceWith("Maybe.zip(s1, s2, zipper)", "io.reactivex.Maybe"),
level = DeprecationLevel.WARNING)
@CheckReturnValue
@SchedulerSupport(SchedulerSupport.NONE)
inline fun <T : Any, U : Any, R : Any> zip(
Expand All @@ -27,6 +31,9 @@ object Maybes {
BiFunction { t, u -> Pair(t, u) })


@Deprecated("New type inference algorithm in Kotlin 1.4 makes this method obsolete. Method will be removed in future RxKotlin release.",
replaceWith = ReplaceWith("Maybe.zip(s1, s2, s3, zipper)", "io.reactivex.Maybe"),
level = DeprecationLevel.WARNING)
@CheckReturnValue
@SchedulerSupport(SchedulerSupport.NONE)
inline fun <T1 : Any, T2 : Any, T3 : Any, R : Any>
Expand All @@ -46,6 +53,9 @@ object Maybes {
): Maybe<Triple<T1, T2, T3>> = Maybe.zip(s1, s2, s3,
Function3 { t1, t2, t3 -> Triple(t1, t2, t3) })

@Deprecated("New type inference algorithm in Kotlin 1.4 makes this method obsolete. Method will be removed in future RxKotlin release.",
replaceWith = ReplaceWith("Maybe.zip(s1, s2, s3, s4, zipper)", "io.reactivex.Maybe"),
level = DeprecationLevel.WARNING)
@CheckReturnValue
@SchedulerSupport(SchedulerSupport.NONE)
inline fun <T1 : Any, T2 : Any, T3 : Any, T4 : Any, R : Any>
Expand All @@ -56,6 +66,9 @@ object Maybes {
): Maybe<R> = Maybe.zip(s1, s2, s3, s4,
Function4 { t1, t2, t3, t4 -> zipper.invoke(t1, t2, t3, t4) })

@Deprecated("New type inference algorithm in Kotlin 1.4 makes this method obsolete. Method will be removed in future RxKotlin release.",
replaceWith = ReplaceWith("Maybe.zip(s1, s2, s3, s4, s5, zipper)", "io.reactivex.Maybe"),
level = DeprecationLevel.WARNING)
@CheckReturnValue
@SchedulerSupport(SchedulerSupport.NONE)
inline fun <T1 : Any, T2 : Any, T3 : Any, T4 : Any, T5 : Any, R : Any>
Expand All @@ -67,6 +80,9 @@ object Maybes {
): Maybe<R> = Maybe.zip(s1, s2, s3, s4, s5,
Function5 { t1, t2, t3, t4, t5 -> zipper.invoke(t1, t2, t3, t4, t5) })

@Deprecated("New type inference algorithm in Kotlin 1.4 makes this method obsolete. Method will be removed in future RxKotlin release.",
replaceWith = ReplaceWith("Maybe.zip(s1, s2, s3, s4, s5, s6, zipper)", "io.reactivex.Maybe"),
level = DeprecationLevel.WARNING)
@CheckReturnValue
@SchedulerSupport(SchedulerSupport.NONE)
inline fun <T1 : Any, T2 : Any, T3 : Any, T4 : Any, T5 : Any, T6 : Any, R : Any>
Expand All @@ -78,6 +94,9 @@ object Maybes {
): Maybe<R> = Maybe.zip(s1, s2, s3, s4, s5, s6,
Function6 { t1, t2, t3, t4, t5, t6 -> zipper.invoke(t1, t2, t3, t4, t5, t6) })

@Deprecated("New type inference algorithm in Kotlin 1.4 makes this method obsolete. Method will be removed in future RxKotlin release.",
replaceWith = ReplaceWith("Maybe.zip(s1, s2, s3, s4, s5, s6, s7, zipper)", "io.reactivex.Maybe"),
level = DeprecationLevel.WARNING)
@CheckReturnValue
@SchedulerSupport(SchedulerSupport.NONE)
inline fun <T1 : Any, T2 : Any, T3 : Any, T4 : Any, T5 : Any, T6 : Any, T7 : Any, R : Any>
Expand All @@ -90,6 +109,9 @@ object Maybes {
): Maybe<R> = Maybe.zip(s1, s2, s3, s4, s5, s6, s7,
Function7 { t1, t2, t3, t4, t5, t6, t7 -> zipper.invoke(t1, t2, t3, t4, t5, t6, t7) })

@Deprecated("New type inference algorithm in Kotlin 1.4 makes this method obsolete. Method will be removed in future RxKotlin release.",
replaceWith = ReplaceWith("Maybe.zip(s1, s2, s3, s4, s5, s6, s7, s8, zipper)", "io.reactivex.Maybe"),
level = DeprecationLevel.WARNING)
@CheckReturnValue
@SchedulerSupport(SchedulerSupport.NONE)
inline fun <T1 : Any, T2 : Any, T3 : Any, T4 : Any, T5 : Any, T6 : Any, T7 : Any, T8 : Any, R : Any>
Expand All @@ -102,6 +124,9 @@ object Maybes {
): Maybe<R> = Maybe.zip(s1, s2, s3, s4, s5, s6, s7, s8,
Function8 { t1, t2, t3, t4, t5, t6, t7, t8 -> zipper.invoke(t1, t2, t3, t4, t5, t6, t7, t8) })

@Deprecated("New type inference algorithm in Kotlin 1.4 makes this method obsolete. Method will be removed in future RxKotlin release.",
replaceWith = ReplaceWith("Maybe.zip(s1, s2, s3, s4, s5, s6, s7, s8, s9, zipper)", "io.reactivex.Maybe"),
level = DeprecationLevel.WARNING)
@CheckReturnValue
@SchedulerSupport(SchedulerSupport.NONE)
inline fun <T1 : Any, T2 : Any, T3 : Any, T4 : Any, T5 : Any, T6 : Any, T7 : Any, T8 : Any, T9 : Any, R : Any>
Expand All @@ -119,6 +144,9 @@ object Maybes {
/**
* An alias to [Maybe.zipWith], but allowing for cleaner lambda syntax.
*/
@Deprecated("New type inference algorithm in Kotlin 1.4 makes this method obsolete. Method will be removed in future RxKotlin release.",
replaceWith = ReplaceWith("zipWith(other, zipper)"),
level = DeprecationLevel.WARNING)
@CheckReturnValue
@SchedulerSupport(SchedulerSupport.NONE)
inline fun <T : Any, U : Any, R : Any> Maybe<T>.zipWith(
Expand Down
Loading

0 comments on commit 3e21313

Please sign in to comment.