Skip to content

Commit c3058da

Browse files
author
jmhofer
committed
added variance to all other Func*; this breaks Scala for good, it seems, as long as Observable remains invariant
1 parent 49a4b2d commit c3058da

File tree

4 files changed

+20
-20
lines changed

4 files changed

+20
-20
lines changed

rxjava-core/src/main/java/rx/Observable.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -992,7 +992,7 @@ public static <T> Observable<Boolean> sequenceEqual(Observable<T> first, Observa
992992
* Observables, results in an item that will be emitted by the resulting Observable
993993
* @return an Observable that emits the zipped results
994994
*/
995-
public static <R, T0, T1, T2> Observable<R> zip(Observable<T0> w0, Observable<T1> w1, Observable<T2> w2, Func3<T0, T1, T2, R> function) {
995+
public static <R, T0, T1, T2> Observable<R> zip(Observable<T0> w0, Observable<T1> w1, Observable<T2> w2, Func3<? super T0, ? super T1, ? super T2, ? extends R> function) {
996996
return create(OperationZip.zip(w0, w1, w2, function));
997997
}
998998

@@ -1023,7 +1023,7 @@ public static <R, T0, T1, T2> Observable<R> zip(Observable<T0> w0, Observable<T1
10231023
* Observables, results in an item that will be emitted by the resulting Observable
10241024
* @return an Observable that emits the zipped results
10251025
*/
1026-
public static <R, T0, T1, T2, T3> Observable<R> zip(Observable<T0> w0, Observable<T1> w1, Observable<T2> w2, Observable<T3> w3, Func4<T0, T1, T2, T3, R> reduceFunction) {
1026+
public static <R, T0, T1, T2, T3> Observable<R> zip(Observable<T0> w0, Observable<T1> w1, Observable<T2> w2, Observable<T3> w3, Func4<? super T0, ? super T1, ? super T2, ? super T3, ? extends R> reduceFunction) {
10271027
return create(OperationZip.zip(w0, w1, w2, w3, reduceFunction));
10281028
}
10291029

@@ -1048,14 +1048,14 @@ public static <R, T0, T1> Observable<R> combineLatest(Observable<T0> w0, Observa
10481048
/**
10491049
* @see #combineLatest(Observable, Observable, Func2)
10501050
*/
1051-
public static <R, T0, T1, T2> Observable<R> combineLatest(Observable<T0> w0, Observable<T1> w1, Observable<T2> w2, Func3<T0, T1, T2, R> combineFunction) {
1051+
public static <R, T0, T1, T2> Observable<R> combineLatest(Observable<T0> w0, Observable<T1> w1, Observable<T2> w2, Func3<? super T0, ? super T1, ? super T2, ? extends R> combineFunction) {
10521052
return create(OperationCombineLatest.combineLatest(w0, w1, w2, combineFunction));
10531053
}
10541054

10551055
/**
10561056
* @see #combineLatest(Observable, Observable, Func2)
10571057
*/
1058-
public static <R, T0, T1, T2, T3> Observable<R> combineLatest(Observable<T0> w0, Observable<T1> w1, Observable<T2> w2, Observable<T3> w3, Func4<T0, T1, T2, T3, R> combineFunction) {
1058+
public static <R, T0, T1, T2, T3> Observable<R> combineLatest(Observable<T0> w0, Observable<T1> w1, Observable<T2> w2, Observable<T3> w3, Func4<? super T0, ? super T1, ? super T2, ? super T3, ? extends R> combineFunction) {
10591059
return create(OperationCombineLatest.combineLatest(w0, w1, w2, w3, combineFunction));
10601060
}
10611061

@@ -1283,7 +1283,7 @@ public Observable<List<T>> buffer(long timespan, long timeshift, TimeUnit unit,
12831283
* Observables, results in an item that will be emitted by the resulting Observable
12841284
* @return an Observable that emits the zipped results
12851285
*/
1286-
public static <R> Observable<R> zip(Observable<Observable<?>> ws, final FuncN<R> reduceFunction) {
1286+
public static <R> Observable<R> zip(Observable<Observable<?>> ws, final FuncN<? extends R> reduceFunction) {
12871287
return ws.toList().mapMany(new Func1<List<Observable<?>>, Observable<R>>() {
12881288
@Override
12891289
public Observable<R> call(List<Observable<?>> wsList) {
@@ -1312,7 +1312,7 @@ public Observable<R> call(List<Observable<?>> wsList) {
13121312
* Observables, results in an item that will be emitted by the resulting Observable
13131313
* @return an Observable that emits the zipped results
13141314
*/
1315-
public static <R> Observable<R> zip(Collection<Observable<?>> ws, FuncN<R> reduceFunction) {
1315+
public static <R> Observable<R> zip(Collection<Observable<?>> ws, FuncN<? extends R> reduceFunction) {
13161316
return create(OperationZip.zip(ws, reduceFunction));
13171317
}
13181318

rxjava-core/src/main/java/rx/operators/OperationCombineLatest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public static <T0, T1, R> Func1<Observer<R>, Subscription> combineLatest(Observa
7272
/**
7373
* @see #combineLatest(Observable w0, Observable w1, Func2 combineLatestFunction)
7474
*/
75-
public static <T0, T1, T2, R> Func1<Observer<R>, Subscription> combineLatest(Observable<T0> w0, Observable<T1> w1, Observable<T2> w2, Func3<T0, T1, T2, ? extends R> combineLatestFunction) {
75+
public static <T0, T1, T2, R> Func1<Observer<R>, Subscription> combineLatest(Observable<T0> w0, Observable<T1> w1, Observable<T2> w2, Func3<? super T0, ? super T1, ? super T2, ? extends R> combineLatestFunction) {
7676
Aggregator<R> a = new Aggregator<R>(Functions.fromFunc(combineLatestFunction));
7777
a.addObserver(new CombineObserver<R, T0>(a, w0));
7878
a.addObserver(new CombineObserver<R, T1>(a, w1));
@@ -83,7 +83,7 @@ public static <T0, T1, T2, R> Func1<Observer<R>, Subscription> combineLatest(Obs
8383
/**
8484
* @see #combineLatest(Observable w0, Observable w1, Func2 combineLatestFunction)
8585
*/
86-
public static <T0, T1, T2, T3, R> Func1<Observer<R>, Subscription> combineLatest(Observable<T0> w0, Observable<T1> w1, Observable<T2> w2, Observable<T3> w3, Func4<T0, T1, T2, T3, ? extends R> combineLatestFunction) {
86+
public static <T0, T1, T2, T3, R> Func1<Observer<R>, Subscription> combineLatest(Observable<T0> w0, Observable<T1> w1, Observable<T2> w2, Observable<T3> w3, Func4<? super T0, ? super T1, ? super T2, ? super T3, ? extends R> combineLatestFunction) {
8787
Aggregator<R> a = new Aggregator<R>(Functions.fromFunc(combineLatestFunction));
8888
a.addObserver(new CombineObserver<R, T0>(a, w0));
8989
a.addObserver(new CombineObserver<R, T1>(a, w1));

rxjava-core/src/main/java/rx/operators/OperationZip.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,15 @@ public static <T0, T1, R> Func1<Observer<R>, Subscription> zip(Observable<T0> w0
6161
return a;
6262
}
6363

64-
public static <T0, T1, T2, R> Func1<Observer<R>, Subscription> zip(Observable<T0> w0, Observable<T1> w1, Observable<T2> w2, Func3<T0, T1, T2, R> zipFunction) {
64+
public static <T0, T1, T2, R> Func1<Observer<R>, Subscription> zip(Observable<T0> w0, Observable<T1> w1, Observable<T2> w2, Func3<? super T0, ? super T1, ? super T2, ? extends R> zipFunction) {
6565
Aggregator<R> a = new Aggregator<R>(Functions.fromFunc(zipFunction));
6666
a.addObserver(new ZipObserver<R, T0>(a, w0));
6767
a.addObserver(new ZipObserver<R, T1>(a, w1));
6868
a.addObserver(new ZipObserver<R, T2>(a, w2));
6969
return a;
7070
}
7171

72-
public static <T0, T1, T2, T3, R> Func1<Observer<R>, Subscription> zip(Observable<T0> w0, Observable<T1> w1, Observable<T2> w2, Observable<T3> w3, Func4<T0, T1, T2, T3, R> zipFunction) {
72+
public static <T0, T1, T2, T3, R> Func1<Observer<R>, Subscription> zip(Observable<T0> w0, Observable<T1> w1, Observable<T2> w2, Observable<T3> w3, Func4<? super T0, ? super T1, ? super T2, ? super T3, ? extends R> zipFunction) {
7373
Aggregator<R> a = new Aggregator<R>(Functions.fromFunc(zipFunction));
7474
a.addObserver(new ZipObserver<R, T0>(a, w0));
7575
a.addObserver(new ZipObserver<R, T1>(a, w1));
@@ -79,7 +79,7 @@ public static <T0, T1, T2, T3, R> Func1<Observer<R>, Subscription> zip(Observabl
7979
}
8080

8181
@SuppressWarnings("unchecked")
82-
public static <R> Func1<Observer<R>, Subscription> zip(Collection<Observable<?>> ws, FuncN<R> zipFunction) {
82+
public static <R> Func1<Observer<R>, Subscription> zip(Collection<Observable<?>> ws, FuncN<? extends R> zipFunction) {
8383
Aggregator<R> a = new Aggregator<R>(zipFunction);
8484
for (@SuppressWarnings("rawtypes") Observable w : ws) {
8585
ZipObserver<R, Object> zipObserver = new ZipObserver<R, Object>(a, w);
@@ -139,7 +139,7 @@ public void onNext(T args) {
139139
private static class Aggregator<T> implements Func1<Observer<T>, Subscription> {
140140

141141
private volatile SynchronizedObserver<T> observer;
142-
private final FuncN<T> zipFunction;
142+
private final FuncN<? extends T> zipFunction;
143143
private final AtomicBoolean started = new AtomicBoolean(false);
144144
private final AtomicBoolean running = new AtomicBoolean(true);
145145
private final ConcurrentHashMap<ZipObserver<T, ?>, Boolean> completed = new ConcurrentHashMap<ZipObserver<T, ?>, Boolean>();
@@ -149,7 +149,7 @@ private static class Aggregator<T> implements Func1<Observer<T>, Subscription> {
149149
/* we use a ConcurrentLinkedQueue to retain ordering (I'd like to just use a ConcurrentLinkedHashMap for 'receivedValuesPerObserver' but that doesn't exist in standard java */
150150
private ConcurrentLinkedQueue<ZipObserver<T, ?>> observers = new ConcurrentLinkedQueue<ZipObserver<T, ?>>();
151151

152-
public Aggregator(FuncN<T> zipFunction) {
152+
public Aggregator(FuncN<? extends T> zipFunction) {
153153
this.zipFunction = zipFunction;
154154
}
155155

rxjava-core/src/main/java/rx/util/functions/Functions.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public R call(Object... args) {
8585
* @param f
8686
* @return {@link FuncN}
8787
*/
88-
public static <T0, T1, T2, R> FuncN<R> fromFunc(final Func3<T0, T1, T2, ? extends R> f) {
88+
public static <T0, T1, T2, R> FuncN<R> fromFunc(final Func3<? super T0, ? super T1, ? super T2, ? extends R> f) {
8989
return new FuncN<R>() {
9090

9191
@SuppressWarnings("unchecked")
@@ -106,7 +106,7 @@ public R call(Object... args) {
106106
* @param f
107107
* @return {@link FuncN}
108108
*/
109-
public static <T0, T1, T2, T3, R> FuncN<R> fromFunc(final Func4<T0, T1, T2, T3, ? extends R> f) {
109+
public static <T0, T1, T2, T3, R> FuncN<R> fromFunc(final Func4<? super T0, ? super T1, ? super T2, ? super T3, ? extends R> f) {
110110
return new FuncN<R>() {
111111

112112
@SuppressWarnings("unchecked")
@@ -127,7 +127,7 @@ public R call(Object... args) {
127127
* @param f
128128
* @return {@link FuncN}
129129
*/
130-
public static <T0, T1, T2, T3, T4, R> FuncN<R> fromFunc(final Func5<T0, T1, T2, T3, T4, ? extends R> f) {
130+
public static <T0, T1, T2, T3, T4, R> FuncN<R> fromFunc(final Func5<? super T0, ? super T1, ? super T2, ? super T3, ? super T4, ? extends R> f) {
131131
return new FuncN<R>() {
132132

133133
@SuppressWarnings("unchecked")
@@ -148,7 +148,7 @@ public R call(Object... args) {
148148
* @param f
149149
* @return {@link FuncN}
150150
*/
151-
public static <T0, T1, T2, T3, T4, T5, R> FuncN<R> fromFunc(final Func6<T0, T1, T2, T3, T4, T5, ? extends R> f) {
151+
public static <T0, T1, T2, T3, T4, T5, R> FuncN<R> fromFunc(final Func6<? super T0, ? super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? extends R> f) {
152152
return new FuncN<R>() {
153153

154154
@SuppressWarnings("unchecked")
@@ -169,7 +169,7 @@ public R call(Object... args) {
169169
* @param f
170170
* @return {@link FuncN}
171171
*/
172-
public static <T0, T1, T2, T3, T4, T5, T6, R> FuncN<R> fromFunc(final Func7<T0, T1, T2, T3, T4, T5, T6, ? extends R> f) {
172+
public static <T0, T1, T2, T3, T4, T5, T6, R> FuncN<R> fromFunc(final Func7<? super T0, ? super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? extends R> f) {
173173
return new FuncN<R>() {
174174

175175
@SuppressWarnings("unchecked")
@@ -190,7 +190,7 @@ public R call(Object... args) {
190190
* @param f
191191
* @return {@link FuncN}
192192
*/
193-
public static <T0, T1, T2, T3, T4, T5, T6, T7, R> FuncN<R> fromFunc(final Func8<T0, T1, T2, T3, T4, T5, T6, T7, ? extends R> f) {
193+
public static <T0, T1, T2, T3, T4, T5, T6, T7, R> FuncN<R> fromFunc(final Func8<? super T0, ? super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? super T7, ? extends R> f) {
194194
return new FuncN<R>() {
195195

196196
@SuppressWarnings("unchecked")
@@ -211,7 +211,7 @@ public R call(Object... args) {
211211
* @param f
212212
* @return {@link FuncN}
213213
*/
214-
public static <T0, T1, T2, T3, T4, T5, T6, T7, T8, R> FuncN<R> fromFunc(final Func9<T0, T1, T2, T3, T4, T5, T6, T7, T8, ? extends R> f) {
214+
public static <T0, T1, T2, T3, T4, T5, T6, T7, T8, R> FuncN<R> fromFunc(final Func9<? super T0, ? super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? super T7, ? super T8, ? extends R> f) {
215215
return new FuncN<R>() {
216216

217217
@SuppressWarnings("unchecked")

0 commit comments

Comments
 (0)