Skip to content
This repository has been archived by the owner. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 0b33327

Browse files
committedJul 14, 2017
Remove any reference to F0 and F1
Syncs up with sbt/util#84.
1 parent d6d5771 commit 0b33327

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed
 

‎src/main/contraband/incremental.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@
187187
{ "name": "maxErrors", "type": "int" },
188188
{
189189
"name": "sourcePositionMapper",
190-
"type": "xsbti.F1<xsbti.Position, xsbti.Position>"
190+
"type": "java.util.function.Function<xsbti.Position, xsbti.Position>"
191191
},
192192
{
193193
"name": "order",

‎src/main/java/xsbti/api/SafeLazy.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,40 +7,43 @@
77

88
package xsbti.api;
99

10+
import java.util.function.Supplier;
11+
1012
/**
1113
* Implement a Scala `lazy val` in Java for the facing sbt interface.
1214
*
1315
* It holds a reference to a thunk that is lazily evaluated and then
1416
* its reference is clear to avoid memory leaks in memory-intensive code.
15-
* It needs to be defined in [[xsbti]] or a subpackage, see
16-
* [[xsbti.api.Lazy]] or [[xsbti.F0]] for similar definitions.
17+
* It needs to be defined in [[xsbti]] or a subpackage, see [[xsbti.api.Lazy]]
18+
* for similar definitions.
1719
*/
1820
public final class SafeLazy {
1921

2022
/* We do not use conversions from and to Scala functions because [[xsbti]]
2123
* cannot hold any reference to Scala code nor the Scala library. */
2224

2325
/** Return a sbt [[xsbti.api.Lazy]] from a given Scala parameterless function. */
24-
public static <T> xsbti.api.Lazy<T> apply(xsbti.F0<T> sbtThunk) {
26+
public static <T> xsbti.api.Lazy<T> apply(Supplier<T> sbtThunk) {
2527
return new Impl<T>(sbtThunk);
2628
}
2729

2830
/** Return a sbt [[xsbti.api.Lazy]] from a strict value. */
2931
public static <T> xsbti.api.Lazy<T> strict(T value) {
3032
// Convert strict parameter to sbt function returning it
31-
return apply(new xsbti.F0<T>() {
32-
public T apply() {
33+
return apply(new Supplier<T>() {
34+
@Override
35+
public T get() {
3336
return value;
3437
}
3538
});
3639
}
3740

3841
private static final class Impl<T> extends xsbti.api.AbstractLazy<T> {
39-
private xsbti.F0<T> thunk;
42+
private Supplier<T> thunk;
4043
private T result;
4144
private boolean flag = false;
4245

43-
Impl(xsbti.F0<T> thunk) {
46+
Impl(Supplier<T> thunk) {
4447
this.thunk = thunk;
4548
}
4649

@@ -52,7 +55,7 @@ private static final class Impl<T> extends xsbti.api.AbstractLazy<T> {
5255
public T get() {
5356
if (flag) return result;
5457
else {
55-
result = thunk.apply();
58+
result = thunk.get();
5659
flag = true;
5760
// Clear reference so that thunk is GC'ed
5861
thunk = null;

0 commit comments

Comments
 (0)
This repository has been archived.