Skip to content

Commit 4bfbbda

Browse files
committed
Adding variance to Try#toEither
1 parent aeb902e commit 4bfbbda

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/main/java/com/jnape/palatable/lambda/adt/Either.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ public static <L, R> Either<L, R> fromMaybe(Maybe<R> maybe, Supplier<L> leftFn)
292292
@SuppressWarnings("unchecked")
293293
public static <E extends Exception, L, R> Either<L, R> trying(CheckedSupplier<E, ? extends R> supplier,
294294
Function<? super E, ? extends L> leftFn) {
295-
return Try.trying(supplier).toEither(leftFn).biMap(id(), id());
295+
return Try.<E, R>trying(supplier::get).toEither(leftFn);
296296
}
297297

298298
/**

src/main/java/com/jnape/palatable/lambda/adt/Try.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public final Either<T, A> toEither() {
125125
* @param <L> the {@link Either} left parameter type
126126
* @return {@link Either} the success value or the mapped left value
127127
*/
128-
public final <L> Either<L, A> toEither(Function<? super T, L> fn) {
128+
public final <L> Either<L, A> toEither(Function<? super T, ? extends L> fn) {
129129
return match(fn.andThen(Either::left), Either::right);
130130
}
131131

0 commit comments

Comments
 (0)