Skip to content

Commit 9c969a5

Browse files
committed
Eliminating warning in Iso in older javac
1 parent 38fe3f7 commit 9c969a5

1 file changed

Lines changed: 21 additions & 14 deletions

File tree

  • src/main/java/com/jnape/palatable/lambda/optics

src/main/java/com/jnape/palatable/lambda/optics/Iso.java

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@
4444
* not vary, a {@link Simple} iso can be used (for instance, in the previous example, <code>stringIntIso</code> could
4545
* have had the simplified <code>Iso.Simple&lt;String, Integer&gt;</code> type).
4646
* <p>
47-
* For more information, read about <a href="https://hackage.haskell.org/package/lens-4.16.1/docs/Control-Lens-Iso.html">isos</a>.
47+
* For more information, read about
48+
* <a href="https://hackage.haskell.org/package/lens-4.16.1/docs/Control-Lens-Iso.html">isos</a>.
4849
*
4950
* @param <S> the larger type for focusing
5051
* @param <T> the larger type for mirrored focusing
@@ -119,10 +120,12 @@ default <U> Iso<S, T, A, B> discardR(Applicative<U, Iso<S, ?, A, B>> appB) {
119120

120121
@Override
121122
default <U> Iso<S, U, A, B> flatMap(Function<? super T, ? extends Monad<U, Iso<S, ?, A, B>>> fn) {
122-
return unIso().fmap(bt -> Fn2.<B, B, U>fn2(fn1(bt.andThen(fn.<Iso<S, U, A, B>>andThen(Applicative::coerce))
123-
.andThen(Iso::unIso)
124-
.andThen(Tuple2::_2)
125-
.andThen(Fn1::fn1))))
123+
//noinspection RedundantTypeArguments
124+
return unIso().fmap(bt -> Fn2.<B, B, U>fn2(
125+
fn1(bt.andThen(fn.<Iso<S, U, A, B>>andThen(Monad<U, Iso<S, ?, A, B>>::coerce))
126+
.andThen(Iso::unIso)
127+
.andThen(Tuple2::_2)
128+
.andThen(Fn1::fn1))))
126129
.fmap(Fn2::uncurry)
127130
.fmap(bbu -> bbu.<B>diMapL(Tuple2::fill))
128131
.into(Iso::iso);
@@ -199,8 +202,10 @@ static <S, T, A, B> Iso<S, T, A, B> iso(
199202
Optic<? super Profunctor<?, ?, ?>, ? super Functor<?, ?>, S, T, A, B> optic) {
200203
return new Iso<S, T, A, B>() {
201204
@Override
202-
public <CoP extends Profunctor<?, ?, ? extends Profunctor<?, ?, ?>>, CoF extends Functor<?, ? extends Functor<?, ?>>, FB extends Functor<B, ? extends CoF>, FT extends Functor<T, ? extends CoF>, PAFB extends Profunctor<A, FB, ? extends CoP>, PSFT extends Profunctor<S, FT, ? extends CoP>> PSFT apply(
203-
PAFB pafb) {
205+
public <CoP extends Profunctor<?, ?, ? extends Profunctor<?, ?, ?>>,
206+
CoF extends Functor<?, ? extends Functor<?, ?>>, FB extends Functor<B, ? extends CoF>,
207+
FT extends Functor<T, ? extends CoF>, PAFB extends Profunctor<A, FB, ? extends CoP>,
208+
PSFT extends Profunctor<S, FT, ? extends CoP>> PSFT apply(PAFB pafb) {
204209
return optic.apply(pafb);
205210
}
206211
};
@@ -250,12 +255,12 @@ default <R> Iso.Simple<R, A> compose(Iso.Simple<R, S> g) {
250255
*/
251256
@SuppressWarnings("overloads")
252257
default <B> Iso.Simple<S, B> andThen(Iso.Simple<A, B> f) {
253-
return adapt(f.compose(this));
258+
return Iso.Simple.adapt(f.compose(this));
254259
}
255260

256261
@Override
257262
default Iso.Simple<A, S> mirror() {
258-
return adapt(Iso.super.mirror());
263+
return Iso.Simple.adapt(Iso.super.mirror());
259264
}
260265

261266
@Override
@@ -265,17 +270,17 @@ default Lens.Simple<S, A> toLens() {
265270

266271
@Override
267272
default <U> Iso.Simple<S, A> discardR(Applicative<U, Iso<S, ?, A, A>> appB) {
268-
return adapt(Iso.super.discardR(appB));
273+
return Iso.Simple.adapt(Iso.super.discardR(appB));
269274
}
270275

271276
@Override
272277
default <B> Iso.Simple<S, B> andThen(Optic.Simple<? super Profunctor<?, ?, ?>, ? super Functor<?, ?>, A, B> f) {
273-
return adapt(Iso.super.andThen(f));
278+
return Iso.Simple.adapt(Iso.super.andThen(f));
274279
}
275280

276281
@Override
277282
default <R> Iso.Simple<R, A> compose(Optic.Simple<? super Profunctor<?, ?, ?>, ? super Functor<?, ?>, R, S> g) {
278-
return adapt(Iso.super.compose(g));
283+
return Iso.Simple.adapt(Iso.super.compose(g));
279284
}
280285

281286
/**
@@ -290,8 +295,10 @@ static <S, A> Iso.Simple<S, A> adapt(
290295
Optic<? super Profunctor<?, ?, ?>, ? super Functor<?, ?>, S, S, A, A> optic) {
291296
return new Iso.Simple<S, A>() {
292297
@Override
293-
public <CoP extends Profunctor<?, ?, ? extends Profunctor<?, ?, ?>>, CoF extends Functor<?, ? extends Functor<?, ?>>, FB extends Functor<A, ? extends CoF>, FT extends Functor<S, ? extends CoF>, PAFB extends Profunctor<A, FB, ? extends CoP>, PSFT extends Profunctor<S, FT, ? extends CoP>> PSFT apply(
294-
PAFB pafb) {
298+
public <CoP extends Profunctor<?, ?, ? extends Profunctor<?, ?, ?>>,
299+
CoF extends Functor<?, ? extends Functor<?, ?>>, FB extends Functor<A, ? extends CoF>,
300+
FT extends Functor<S, ? extends CoF>, PAFB extends Profunctor<A, FB, ? extends CoP>,
301+
PSFT extends Profunctor<S, FT, ? extends CoP>> PSFT apply(PAFB pafb) {
295302
return optic.apply(pafb);
296303
}
297304
};

0 commit comments

Comments
 (0)