Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions core/src/main/java/fj/control/Trampoline.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,12 @@ public <B> Trampoline<B> bind(final F<A, Trampoline<B>> f) {
// The resumption of a Codense is the resumption of its subcomputation. If that computation is done, its result
// gets shifted into the continuation.
public Either<P1<Trampoline<A>>, A> resume() {
return left(sub.resume().either(p -> p.map(ot -> {
// WARNING: In JDK 8, update 25 (current version) the following code is a
// workaround for an internal JDK compiler error, likely due to
// https:bugs.openjdk.java.net/browse/JDK-8062253.
F<Normal<Object>, Trampoline<A>> f = o -> o.foldNormal(cont, t -> t._1().bind(cont));
F<Codense<Object>, Trampoline<A>> g = c -> codense(c.sub, o -> c.cont.f(o).bind(cont));
return ot.fold(f, g);
}), o -> P.lazy(() -> cont.f(o))));
return left(sub.resume().either(p -> p.map(ot ->
ot.fold(
o -> o.foldNormal(cont, t -> t._1().bind(cont)),
c -> codense(c.sub, o -> c.cont.f(o).bind(cont))
)
), o -> P.lazy(() -> cont.f(o))));
}
}

Expand Down
5 changes: 1 addition & 4 deletions core/src/main/java/fj/data/List.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,7 @@ public final Iterator<A> iterator() {
* @return The length of this list.
*/
public final int length() {
// WARNING: In JDK 8, update 25 (current version) the following code triggers an internal JDK compiler error, likely due to https://bugs.openjdk.java.net/browse/JDK-8062253. The code below is a workaround for this compiler bug.
// return foldLeft(i -> a -> i + 1, 0);
F2<Integer, A, Integer> f = (i, a) -> i + 1;
return foldLeft(f, 0);
return foldLeft((i, a) -> i + 1, 0);
}

/**
Expand Down