Use Unit instead of Void
This commit is contained in:
committed by
Alexander Udalov
parent
2e585f88a3
commit
00c3156b59
+4
-3
@@ -23,6 +23,7 @@ import com.google.common.collect.Lists;
|
|||||||
import com.intellij.psi.PsiElement;
|
import com.intellij.psi.PsiElement;
|
||||||
import jet.Function0;
|
import jet.Function0;
|
||||||
import jet.Function1;
|
import jet.Function1;
|
||||||
|
import jet.Unit;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.lang.descriptors.*;
|
import org.jetbrains.jet.lang.descriptors.*;
|
||||||
@@ -401,11 +402,11 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements LazyDesc
|
|||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new Function1<Collection<JetType>, Void>() {
|
new Function1<Collection<JetType>, Unit>() {
|
||||||
@Override
|
@Override
|
||||||
public Void invoke(@NotNull Collection<JetType> supertypes) {
|
public Unit invoke(@NotNull Collection<JetType> supertypes) {
|
||||||
findAndDisconnectLoopsInTypeHierarchy(supertypes);
|
findAndDisconnectLoopsInTypeHierarchy(supertypes);
|
||||||
return null;
|
return Unit.VALUE;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package org.jetbrains.jet.storage;
|
|||||||
|
|
||||||
import jet.Function0;
|
import jet.Function0;
|
||||||
import jet.Function1;
|
import jet.Function1;
|
||||||
|
import jet.Unit;
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
import org.jetbrains.jet.util.ReenteringLazyValueComputationException;
|
import org.jetbrains.jet.util.ReenteringLazyValueComputationException;
|
||||||
|
|
||||||
@@ -238,10 +239,10 @@ public class StorageManagerTest extends TestCase {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
null,
|
null,
|
||||||
new Function1<String, Void>() {
|
new Function1<String, Unit>() {
|
||||||
@Override
|
@Override
|
||||||
public Void invoke(String s) {
|
public Unit invoke(String s) {
|
||||||
return null;
|
return Unit.VALUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -272,12 +273,12 @@ public class StorageManagerTest extends TestCase {
|
|||||||
return "tolerant";
|
return "tolerant";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new Function1<String, Void>() {
|
new Function1<String, Unit>() {
|
||||||
@Override
|
@Override
|
||||||
public Void invoke(String s) {
|
public Unit invoke(String s) {
|
||||||
counter.inc();
|
counter.inc();
|
||||||
assertEquals("tolerant", s);
|
assertEquals("tolerant", s);
|
||||||
return null;
|
return Unit.VALUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -301,12 +302,12 @@ public class StorageManagerTest extends TestCase {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
null,
|
null,
|
||||||
new Function1<Collection<String>, Void>() {
|
new Function1<Collection<String>, Unit>() {
|
||||||
@Override
|
@Override
|
||||||
public Void invoke(Collection<String> strings) {
|
public Unit invoke(Collection<String> strings) {
|
||||||
counter.inc();
|
counter.inc();
|
||||||
strings.add("postComputed");
|
strings.add("postComputed");
|
||||||
return null;
|
return Unit.VALUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -327,12 +328,12 @@ public class StorageManagerTest extends TestCase {
|
|||||||
return strings;
|
return strings;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new Function1<Collection<String>, Void>() {
|
new Function1<Collection<String>, Unit>() {
|
||||||
@Override
|
@Override
|
||||||
public Void invoke(Collection<String> strings) {
|
public Unit invoke(Collection<String> strings) {
|
||||||
counter.inc();
|
counter.inc();
|
||||||
strings.add("postComputed");
|
strings.add("postComputed");
|
||||||
return null;
|
return Unit.VALUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -361,11 +362,11 @@ public class StorageManagerTest extends TestCase {
|
|||||||
return "second";
|
return "second";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new Function1<String, Void>() {
|
new Function1<String, Unit>() {
|
||||||
@Override
|
@Override
|
||||||
public Void invoke(String s) {
|
public Unit invoke(String s) {
|
||||||
fail("Recursion-tolerating value should not be post computed");
|
fail("Recursion-tolerating value should not be post computed");
|
||||||
return null;
|
return Unit.VALUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ package org.jetbrains.jet.storage;
|
|||||||
|
|
||||||
import jet.Function0;
|
import jet.Function0;
|
||||||
import jet.Function1;
|
import jet.Function1;
|
||||||
|
import jet.Unit;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.utils.ExceptionUtils;
|
import org.jetbrains.jet.utils.ExceptionUtils;
|
||||||
@@ -99,7 +100,7 @@ public class LockBasedStorageManager implements StorageManager {
|
|||||||
public <T> NotNullLazyValue<T> createLazyValueWithPostCompute(
|
public <T> NotNullLazyValue<T> createLazyValueWithPostCompute(
|
||||||
@NotNull Function0<T> computable,
|
@NotNull Function0<T> computable,
|
||||||
final Function1<Boolean, T> onRecursiveCall,
|
final Function1<Boolean, T> onRecursiveCall,
|
||||||
@NotNull final Function1<T, Void> postCompute
|
@NotNull final Function1<T, Unit> postCompute
|
||||||
) {
|
) {
|
||||||
return new LockBasedNotNullLazyValue<T>(lock, computable) {
|
return new LockBasedNotNullLazyValue<T>(lock, computable) {
|
||||||
@Nullable
|
@Nullable
|
||||||
@@ -138,7 +139,7 @@ public class LockBasedStorageManager implements StorageManager {
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public <T> NullableLazyValue<T> createNullableLazyValueWithPostCompute(
|
public <T> NullableLazyValue<T> createNullableLazyValueWithPostCompute(
|
||||||
@NotNull Function0<T> computable, @NotNull final Function1<T, Void> postCompute
|
@NotNull Function0<T> computable, @NotNull final Function1<T, Unit> postCompute
|
||||||
) {
|
) {
|
||||||
return new LockBasedLazyValue<T>(lock, computable) {
|
return new LockBasedLazyValue<T>(lock, computable) {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ package org.jetbrains.jet.storage;
|
|||||||
|
|
||||||
import jet.Function0;
|
import jet.Function0;
|
||||||
import jet.Function1;
|
import jet.Function1;
|
||||||
|
import jet.Unit;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
@@ -28,6 +29,7 @@ public interface StorageManager {
|
|||||||
* @param valuesReferenceKind how to store the memoized values
|
* @param valuesReferenceKind how to store the memoized values
|
||||||
*
|
*
|
||||||
* NOTE: if compute() has side-effects the WEAK reference kind is dangerous: the side-effects will be repeated if
|
* NOTE: if compute() has side-effects the WEAK reference kind is dangerous: the side-effects will be repeated if
|
||||||
|
* the value gets collected and then re-computed
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
<K, V> MemoizedFunctionToNotNull<K, V> createMemoizedFunction(@NotNull Function1<K, V> compute);
|
<K, V> MemoizedFunctionToNotNull<K, V> createMemoizedFunction(@NotNull Function1<K, V> compute);
|
||||||
@@ -41,7 +43,6 @@ public interface StorageManager {
|
|||||||
<T> NotNullLazyValue<T> createRecursionTolerantLazyValue(@NotNull Function0<T> computable, @NotNull T onRecursiveCall);
|
<T> NotNullLazyValue<T> createRecursionTolerantLazyValue(@NotNull Function0<T> computable, @NotNull T onRecursiveCall);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param computable
|
|
||||||
* @param onRecursiveCall is called if the computation calls itself recursively.
|
* @param onRecursiveCall is called if the computation calls itself recursively.
|
||||||
* The parameter to it is {@code true} for the first call, {@code false} otherwise.
|
* The parameter to it is {@code true} for the first call, {@code false} otherwise.
|
||||||
* If {@code onRecursiveCall} is {@code null}, an exception will be thrown on a recursive call,
|
* If {@code onRecursiveCall} is {@code null}, an exception will be thrown on a recursive call,
|
||||||
@@ -52,7 +53,7 @@ public interface StorageManager {
|
|||||||
<T> NotNullLazyValue<T> createLazyValueWithPostCompute(
|
<T> NotNullLazyValue<T> createLazyValueWithPostCompute(
|
||||||
@NotNull Function0<T> computable,
|
@NotNull Function0<T> computable,
|
||||||
@Nullable Function1<Boolean, T> onRecursiveCall,
|
@Nullable Function1<Boolean, T> onRecursiveCall,
|
||||||
@NotNull Function1<T, Void> postCompute
|
@NotNull Function1<T, Unit> postCompute
|
||||||
);
|
);
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -66,7 +67,7 @@ public interface StorageManager {
|
|||||||
* see it in between)
|
* see it in between)
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
<T> NullableLazyValue<T> createNullableLazyValueWithPostCompute(@NotNull Function0<T> computable, @NotNull Function1<T, Void> postCompute);
|
<T> NullableLazyValue<T> createNullableLazyValueWithPostCompute(@NotNull Function0<T> computable, @NotNull Function1<T, Unit> postCompute);
|
||||||
|
|
||||||
<T> T compute(@NotNull Function0<T> computable);
|
<T> T compute(@NotNull Function0<T> computable);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user