Skip to content

Commit 1a5baf8

Browse files
krossovochkinthomasnield
authored andcommitted
Fix extensions to fail in compile time on nullable types (#201)
1 parent c8c4f9d commit 1a5baf8

File tree

4 files changed

+81
-81
lines changed

4 files changed

+81
-81
lines changed

src/main/kotlin/io/reactivex/rxkotlin/Flowables.kt

+29-29
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ object Flowables {
1818
@CheckReturnValue
1919
@BackpressureSupport(BackpressureKind.FULL)
2020
@SchedulerSupport(SchedulerSupport.NONE)
21-
inline fun <T1,T2,R> combineLatest(source1: Flowable<T1>, source2: Flowable<T2>, crossinline combineFunction: (T1, T2) -> R) =
21+
inline fun <T1 : Any, T2 : Any, R : Any> combineLatest(source1: Flowable<T1>, source2: Flowable<T2>, crossinline combineFunction: (T1, T2) -> R) =
2222
Flowable.combineLatest(source1, source2,
2323
BiFunction<T1, T2, R> { t1, t2 -> combineFunction(t1,t2) })!!
2424

@@ -28,15 +28,15 @@ object Flowables {
2828
@CheckReturnValue
2929
@BackpressureSupport(BackpressureKind.FULL)
3030
@SchedulerSupport(SchedulerSupport.NONE)
31-
fun <T1,T2> combineLatest(source1: Flowable<T1>, source2: Flowable<T2>) =
31+
fun <T1 : Any, T2 : Any> combineLatest(source1: Flowable<T1>, source2: Flowable<T2>) =
3232
Flowable.combineLatest(source1, source2,
3333
BiFunction<T1, T2, Pair<T1,T2>> { t1, t2 -> t1 to t2 })!!
3434

3535

3636
@CheckReturnValue
3737
@BackpressureSupport(BackpressureKind.FULL)
3838
@SchedulerSupport(SchedulerSupport.NONE)
39-
inline fun <T1,T2,T3,R> combineLatest(source1: Flowable<T1>, source2: Flowable<T2>, source3: Flowable<T3>, crossinline combineFunction: (T1,T2, T3) -> R) =
39+
inline fun <T1 : Any, T2 : Any, T3 : Any, R : Any> combineLatest(source1: Flowable<T1>, source2: Flowable<T2>, source3: Flowable<T3>, crossinline combineFunction: (T1,T2, T3) -> R) =
4040
Flowable.combineLatest(source1, source2,source3,
4141
Function3{ t1: T1, t2: T2, t3: T3 -> combineFunction(t1,t2, t3) })!!
4242

@@ -46,15 +46,15 @@ object Flowables {
4646
@CheckReturnValue
4747
@BackpressureSupport(BackpressureKind.FULL)
4848
@SchedulerSupport(SchedulerSupport.NONE)
49-
fun <T1,T2,T3> combineLatest(source1: Flowable<T1>, source2: Flowable<T2>, source3: Flowable<T3>) =
49+
fun <T1 : Any, T2 : Any, T3 : Any> combineLatest(source1: Flowable<T1>, source2: Flowable<T2>, source3: Flowable<T3>) =
5050
Flowable.combineLatest(source1, source2, source3,
5151
Function3<T1, T2, T3, Triple<T1,T2,T3>> { t1, t2, t3 -> Triple(t1,t2,t3) })!!
5252

5353

5454
@CheckReturnValue
5555
@BackpressureSupport(BackpressureKind.FULL)
5656
@SchedulerSupport(SchedulerSupport.NONE)
57-
inline fun <T1,T2,T3,T4,R> combineLatest(source1: Flowable<T1>, source2: Flowable<T2>, source3: Flowable<T3>,
57+
inline fun <T1 : Any, T2 : Any, T3 : Any, T4 : Any, R : Any> combineLatest(source1: Flowable<T1>, source2: Flowable<T2>, source3: Flowable<T3>,
5858
source4: Flowable<T4>, crossinline combineFunction: (T1,T2, T3, T4) -> R) =
5959
Flowable.combineLatest(source1, source2,source3, source4,
6060
Function4 { t1: T1, t2: T2, t3: T3, t4: T4 -> combineFunction(t1,t2, t3, t4) })!!
@@ -63,7 +63,7 @@ object Flowables {
6363
@CheckReturnValue
6464
@BackpressureSupport(BackpressureKind.FULL)
6565
@SchedulerSupport(SchedulerSupport.NONE)
66-
inline fun <T1,T2,T3,T4,T5,R> combineLatest(source1: Flowable<T1>, source2: Flowable<T2>,
66+
inline fun <T1 : Any, T2 : Any, T3 : Any, T4 : Any, T5 : Any, R : Any> combineLatest(source1: Flowable<T1>, source2: Flowable<T2>,
6767
source3: Flowable<T3>, source4: Flowable<T4>,
6868
source5: Flowable<T5>, crossinline combineFunction: (T1,T2, T3, T4, T5) -> R) =
6969
Flowable.combineLatest(source1, source2,source3, source4, source5,
@@ -73,7 +73,7 @@ object Flowables {
7373
@CheckReturnValue
7474
@BackpressureSupport(BackpressureKind.FULL)
7575
@SchedulerSupport(SchedulerSupport.NONE)
76-
inline fun <T1,T2,T3,T4,T5,T6,R> combineLatest(source1: Flowable<T1>, source2: Flowable<T2>,
76+
inline fun <T1 : Any, T2 : Any, T3 : Any, T4 : Any, T5 : Any, T6 : Any, R : Any> combineLatest(source1: Flowable<T1>, source2: Flowable<T2>,
7777
source3: Flowable<T3>, source4: Flowable<T4>,
7878
source5: Flowable<T5>, source6: Flowable<T6>, crossinline combineFunction: (T1,T2, T3, T4, T5, T6) -> R) =
7979
Flowable.combineLatest(source1, source2,source3, source4, source5, source6,
@@ -82,7 +82,7 @@ object Flowables {
8282
@CheckReturnValue
8383
@BackpressureSupport(BackpressureKind.FULL)
8484
@SchedulerSupport(SchedulerSupport.NONE)
85-
inline fun <T1,T2,T3,T4,T5,T6,T7,R> combineLatest(source1: Flowable<T1>, source2: Flowable<T2>,
85+
inline fun <T1 : Any, T2 : Any, T3 : Any, T4 : Any, T5 : Any, T6 : Any, T7 : Any, R : Any> combineLatest(source1: Flowable<T1>, source2: Flowable<T2>,
8686
source3: Flowable<T3>, source4: Flowable<T4>,
8787
source5: Flowable<T5>, source6: Flowable<T6>,
8888
source7: Flowable<T7>, crossinline combineFunction: (T1,T2, T3, T4, T5, T6, T7) -> R) =
@@ -93,7 +93,7 @@ object Flowables {
9393
@CheckReturnValue
9494
@BackpressureSupport(BackpressureKind.FULL)
9595
@SchedulerSupport(SchedulerSupport.NONE)
96-
inline fun <T1,T2,T3,T4,T5,T6,T7,T8,R> combineLatest(source1: Flowable<T1>, source2: Flowable<T2>,
96+
inline fun <T1 : Any, T2 : Any, T3 : Any, T4 : Any, T5 : Any, T6 : Any, T7 : Any, T8 : Any, R : Any> combineLatest(source1: Flowable<T1>, source2: Flowable<T2>,
9797
source3: Flowable<T3>, source4: Flowable<T4>,
9898
source5: Flowable<T5>, source6: Flowable<T6>,
9999
source7: Flowable<T7>, source8: Flowable<T8>,
@@ -104,7 +104,7 @@ object Flowables {
104104
@CheckReturnValue
105105
@BackpressureSupport(BackpressureKind.FULL)
106106
@SchedulerSupport(SchedulerSupport.NONE)
107-
inline fun <T1,T2,T3,T4,T5,T6,T7,T8,T9,R> combineLatest(source1: Flowable<T1>, source2: Flowable<T2>,
107+
inline fun <T1 : Any, T2 : Any, T3 : Any, T4 : Any, T5 : Any, T6 : Any, T7 : Any, T8 : Any, T9 : Any, R : Any> combineLatest(source1: Flowable<T1>, source2: Flowable<T2>,
108108
source3: Flowable<T3>, source4: Flowable<T4>,
109109
source5: Flowable<T5>, source6: Flowable<T6>,
110110
source7: Flowable<T7>, source8: Flowable<T8>,
@@ -118,7 +118,7 @@ object Flowables {
118118
@CheckReturnValue
119119
@BackpressureSupport(BackpressureKind.SPECIAL)
120120
@SchedulerSupport(SchedulerSupport.NONE)
121-
inline fun <T> create(mode: BackpressureStrategy, crossinline source: (FlowableEmitter<T>) -> Unit) =
121+
inline fun <T : Any> create(mode: BackpressureStrategy, crossinline source: (FlowableEmitter<T>) -> Unit) =
122122
Flowable.create<T>({ source(it) }, mode)!!
123123

124124

@@ -127,7 +127,7 @@ object Flowables {
127127
@CheckReturnValue
128128
@BackpressureSupport(BackpressureKind.FULL)
129129
@SchedulerSupport(SchedulerSupport.NONE)
130-
inline fun <T1,T2,R> zip(source1: Flowable<T1>, source2: Flowable<T2>, crossinline combineFunction: (T1, T2) -> R) =
130+
inline fun <T1 : Any, T2 : Any, R : Any> zip(source1: Flowable<T1>, source2: Flowable<T2>, crossinline combineFunction: (T1, T2) -> R) =
131131
Flowable.zip(source1, source2,
132132
BiFunction<T1, T2, R> { t1, t2 -> combineFunction(t1,t2) })!!
133133

@@ -137,15 +137,15 @@ object Flowables {
137137
@CheckReturnValue
138138
@BackpressureSupport(BackpressureKind.FULL)
139139
@SchedulerSupport(SchedulerSupport.NONE)
140-
fun <T1,T2> zip(source1: Flowable<T1>, source2: Flowable<T2>) =
140+
fun <T1 : Any, T2 : Any> zip(source1: Flowable<T1>, source2: Flowable<T2>) =
141141
Flowable.zip(source1, source2,
142142
BiFunction<T1, T2, Pair<T1,T2>> { t1, t2 -> t1 to t2 })!!
143143

144144

145145
@CheckReturnValue
146146
@BackpressureSupport(BackpressureKind.FULL)
147147
@SchedulerSupport(SchedulerSupport.NONE)
148-
inline fun <T1,T2,T3,R> zip(source1: Flowable<T1>, source2: Flowable<T2>, source3: Flowable<T3>, crossinline combineFunction: (T1,T2, T3) -> R) =
148+
inline fun <T1 : Any, T2 : Any, T3 : Any, R : Any> zip(source1: Flowable<T1>, source2: Flowable<T2>, source3: Flowable<T3>, crossinline combineFunction: (T1,T2, T3) -> R) =
149149
Flowable.zip(source1, source2,source3,
150150
Function3 { t1: T1, t2: T2, t3: T3 -> combineFunction(t1,t2, t3) })!!
151151

@@ -155,21 +155,21 @@ object Flowables {
155155
@CheckReturnValue
156156
@BackpressureSupport(BackpressureKind.FULL)
157157
@SchedulerSupport(SchedulerSupport.NONE)
158-
fun <T1,T2,T3> zip(source1: Flowable<T1>, source2: Flowable<T2>, source3: Flowable<T3>) =
158+
fun <T1 : Any, T2 : Any, T3 : Any> zip(source1: Flowable<T1>, source2: Flowable<T2>, source3: Flowable<T3>) =
159159
Flowable.zip(source1, source2, source3,
160160
Function3<T1, T2, T3, Triple<T1,T2,T3>> { t1, t2, t3 -> Triple(t1,t2,t3) })!!
161161

162162
@CheckReturnValue
163163
@BackpressureSupport(BackpressureKind.FULL)
164164
@SchedulerSupport(SchedulerSupport.NONE)
165-
inline fun <T1,T2,T3,T4,R> zip(source1: Flowable<T1>, source2: Flowable<T2>, source3: Flowable<T3>, source4: Flowable<T4>, crossinline combineFunction: (T1,T2, T3, T4) -> R) =
165+
inline fun <T1 : Any, T2 : Any, T3 : Any, T4 : Any, R : Any> zip(source1: Flowable<T1>, source2: Flowable<T2>, source3: Flowable<T3>, source4: Flowable<T4>, crossinline combineFunction: (T1,T2, T3, T4) -> R) =
166166
Flowable.zip(source1, source2,source3, source4,
167167
Function4 { t1: T1, t2: T2, t3: T3, t4: T4 -> combineFunction(t1,t2, t3, t4) })!!
168168

169169
@CheckReturnValue
170170
@BackpressureSupport(BackpressureKind.FULL)
171171
@SchedulerSupport(SchedulerSupport.NONE)
172-
inline fun <T1,T2,T3,T4,T5,R> zip(source1: Flowable<T1>, source2: Flowable<T2>,
172+
inline fun <T1 : Any, T2 : Any, T3 : Any, T4 : Any, T5 : Any, R : Any> zip(source1: Flowable<T1>, source2: Flowable<T2>,
173173
source3: Flowable<T3>, source4: Flowable<T4>,
174174
source5: Flowable<T5>, crossinline combineFunction: (T1,T2, T3, T4, T5) -> R) =
175175
Flowable.zip(source1, source2,source3, source4, source5,
@@ -180,7 +180,7 @@ object Flowables {
180180
@CheckReturnValue
181181
@BackpressureSupport(BackpressureKind.FULL)
182182
@SchedulerSupport(SchedulerSupport.NONE)
183-
inline fun <T1,T2,T3,T4,T5,T6,R> zip(source1: Flowable<T1>, source2: Flowable<T2>,
183+
inline fun <T1 : Any, T2 : Any, T3 : Any, T4 : Any, T5 : Any, T6 : Any, R : Any> zip(source1: Flowable<T1>, source2: Flowable<T2>,
184184
source3: Flowable<T3>, source4: Flowable<T4>,
185185
source5: Flowable<T5>, source6: Flowable<T6>, crossinline combineFunction: (T1,T2, T3, T4, T5, T6) -> R) =
186186
Flowable.zip(source1, source2,source3, source4, source5, source6,
@@ -189,7 +189,7 @@ object Flowables {
189189
@CheckReturnValue
190190
@BackpressureSupport(BackpressureKind.FULL)
191191
@SchedulerSupport(SchedulerSupport.NONE)
192-
inline fun <T1,T2,T3,T4,T5,T6,T7,R> zip(source1: Flowable<T1>, source2: Flowable<T2>,
192+
inline fun <T1 : Any, T2 : Any, T3 : Any, T4 : Any, T5 : Any, T6 : Any, T7 : Any, R : Any> zip(source1: Flowable<T1>, source2: Flowable<T2>,
193193
source3: Flowable<T3>, source4: Flowable<T4>,
194194
source5: Flowable<T5>, source6: Flowable<T6>,
195195
source7: Flowable<T7>, crossinline combineFunction: (T1,T2, T3, T4, T5, T6, T7) -> R) =
@@ -200,7 +200,7 @@ object Flowables {
200200
@CheckReturnValue
201201
@BackpressureSupport(BackpressureKind.FULL)
202202
@SchedulerSupport(SchedulerSupport.NONE)
203-
inline fun <T1,T2,T3,T4,T5,T6,T7,T8,R> zip(source1: Flowable<T1>, source2: Flowable<T2>,
203+
inline fun <T1 : Any, T2 : Any, T3 : Any, T4 : Any, T5 : Any, T6 : Any, T7 : Any, T8 : Any, R : Any> zip(source1: Flowable<T1>, source2: Flowable<T2>,
204204
source3: Flowable<T3>, source4: Flowable<T4>,
205205
source5: Flowable<T5>, source6: Flowable<T6>,
206206
source7: Flowable<T7>, source8: Flowable<T8>,
@@ -211,7 +211,7 @@ object Flowables {
211211
@CheckReturnValue
212212
@BackpressureSupport(BackpressureKind.FULL)
213213
@SchedulerSupport(SchedulerSupport.NONE)
214-
inline fun <T1,T2,T3,T4,T5,T6,T7,T8,T9,R> zip(source1: Flowable<T1>, source2: Flowable<T2>,
214+
inline fun <T1 : Any, T2 : Any, T3 : Any, T4 : Any, T5 : Any, T6 : Any, T7 : Any, T8 : Any, T9 : Any, R : Any> zip(source1: Flowable<T1>, source2: Flowable<T2>,
215215
source3: Flowable<T3>, source4: Flowable<T4>,
216216
source5: Flowable<T5>, source6: Flowable<T6>,
217217
source7: Flowable<T7>, source8: Flowable<T8>,
@@ -227,13 +227,13 @@ object Flowables {
227227
@CheckReturnValue
228228
@BackpressureSupport(BackpressureKind.PASS_THROUGH)
229229
@SchedulerSupport(SchedulerSupport.NONE)
230-
inline fun <T, U, R> Flowable<T>.withLatestFrom(other: Publisher<U>, crossinline combiner: (T, U) -> R): Flowable<R>
230+
inline fun <T : Any, U : Any, R : Any> Flowable<T>.withLatestFrom(other: Publisher<U>, crossinline combiner: (T, U) -> R): Flowable<R>
231231
= withLatestFrom(other, BiFunction<T, U, R> { t, u -> combiner.invoke(t, u) })
232232

233233
@CheckReturnValue
234234
@BackpressureSupport(BackpressureKind.PASS_THROUGH)
235235
@SchedulerSupport(SchedulerSupport.NONE)
236-
fun <T, U> Flowable<T>.withLatestFrom(other: Publisher<U>): Flowable<Pair<T, U>>
236+
fun <T : Any, U : Any> Flowable<T>.withLatestFrom(other: Publisher<U>): Flowable<Pair<T, U>>
237237
= withLatestFrom(other, BiFunction{ t, u -> Pair(t,u) })
238238

239239

@@ -243,13 +243,13 @@ fun <T, U> Flowable<T>.withLatestFrom(other: Publisher<U>): Flowable<Pair<T, U>>
243243
@CheckReturnValue
244244
@BackpressureSupport(BackpressureKind.PASS_THROUGH)
245245
@SchedulerSupport(SchedulerSupport.NONE)
246-
inline fun <T, T1, T2, R> Flowable<T>.withLatestFrom(o1: Publisher<T1>, o2: Publisher<T2>, crossinline combiner: (T, T1, T2) -> R): Flowable<R>
246+
inline fun <T : Any, T1 : Any, T2 : Any, R : Any> Flowable<T>.withLatestFrom(o1: Publisher<T1>, o2: Publisher<T2>, crossinline combiner: (T, T1, T2) -> R): Flowable<R>
247247
= withLatestFrom(o1, o2, Function3 { t, t1, t2 -> combiner.invoke(t, t1, t2) })
248248

249249
@CheckReturnValue
250250
@BackpressureSupport(BackpressureKind.PASS_THROUGH)
251251
@SchedulerSupport(SchedulerSupport.NONE)
252-
fun <T, T1, T2> Flowable<T>.withLatestFrom(o1: Publisher<T1>, o2: Publisher<T2>): Flowable<Triple<T,T1,T2>>
252+
fun <T : Any, T1 : Any, T2 : Any> Flowable<T>.withLatestFrom(o1: Publisher<T1>, o2: Publisher<T2>): Flowable<Triple<T,T1,T2>>
253253
= withLatestFrom(o1, o2, Function3 { t, t1, t2 -> Triple(t, t1, t2) })
254254

255255
/**
@@ -258,7 +258,7 @@ fun <T, T1, T2> Flowable<T>.withLatestFrom(o1: Publisher<T1>, o2: Publisher<T2>)
258258
@CheckReturnValue
259259
@BackpressureSupport(BackpressureKind.PASS_THROUGH)
260260
@SchedulerSupport(SchedulerSupport.NONE)
261-
inline fun <T, T1, T2, T3, R> Flowable<T>.withLatestFrom(o1: Publisher<T1>, o2: Publisher<T2>, o3: Publisher<T3>, crossinline combiner: (T, T1, T2, T3) -> R): Flowable<R>
261+
inline fun <T : Any, T1 : Any, T2 : Any, T3 : Any, R : Any> Flowable<T>.withLatestFrom(o1: Publisher<T1>, o2: Publisher<T2>, o3: Publisher<T3>, crossinline combiner: (T, T1, T2, T3) -> R): Flowable<R>
262262
= withLatestFrom(o1, o2, o3, Function4 { t, t1, t2, t3 -> combiner.invoke(t, t1, t2, t3) })
263263

264264
/**
@@ -267,7 +267,7 @@ inline fun <T, T1, T2, T3, R> Flowable<T>.withLatestFrom(o1: Publisher<T1>, o2:
267267
@CheckReturnValue
268268
@BackpressureSupport(BackpressureKind.FULL)
269269
@SchedulerSupport(SchedulerSupport.NONE)
270-
inline fun <T, T1, T2, T3, T4, R> Flowable<T>.withLatestFrom(o1: Publisher<T1>, o2: Publisher<T2>, o3: Publisher<T3>, o4: Publisher<T4>, crossinline combiner: (T, T1, T2, T3, T4) -> R): Flowable<R>
270+
inline fun <T : Any, T1 : Any, T2 : Any, T3 : Any, T4 : Any, R : Any> Flowable<T>.withLatestFrom(o1: Publisher<T1>, o2: Publisher<T2>, o3: Publisher<T3>, o4: Publisher<T4>, crossinline combiner: (T, T1, T2, T3, T4) -> R): Flowable<R>
271271
= withLatestFrom(o1, o2, o3, o4, Function5 { t, t1, t2, t3, t4 -> combiner.invoke(t, t1, t2, t3, t4) })
272272

273273
/**
@@ -276,7 +276,7 @@ inline fun <T, T1, T2, T3, T4, R> Flowable<T>.withLatestFrom(o1: Publisher<T1>,
276276
@CheckReturnValue
277277
@BackpressureSupport(BackpressureKind.PASS_THROUGH)
278278
@SchedulerSupport(SchedulerSupport.NONE)
279-
inline fun <T, U, R> Flowable<T>.zipWith(other: Publisher<U>, crossinline zipper: (T, U) -> R): Flowable<R>
279+
inline fun <T : Any, U : Any, R : Any> Flowable<T>.zipWith(other: Publisher<U>, crossinline zipper: (T, U) -> R): Flowable<R>
280280
= zipWith(other, BiFunction { t, u -> zipper.invoke(t, u) })
281281

282282
/**
@@ -285,5 +285,5 @@ inline fun <T, U, R> Flowable<T>.zipWith(other: Publisher<U>, crossinline zipper
285285
@CheckReturnValue
286286
@BackpressureSupport(BackpressureKind.FULL)
287287
@SchedulerSupport(SchedulerSupport.NONE)
288-
fun <T, U> Flowable<T>.zipWith(other: Publisher<U>): Flowable<Pair<T, U>>
288+
fun <T : Any, U : Any> Flowable<T>.zipWith(other: Publisher<U>): Flowable<Pair<T, U>>
289289
= zipWith(other, BiFunction { t, u -> Pair(t,u) })

0 commit comments

Comments
 (0)